Skip to content

๐ŸŒ Server-Side Rendering with vue-leaflet โ€‹

INFO

This guide applies only to Leaflet v2 and the official vue-leaflet wrapper. Leaflet v1 plugins and components are not supported.

Vue-Leaflet v2 is designed to work seamlessly in SSR environments like Nuxt 4 and Vite, enabling fast, SEO-friendly map applications without sacrificing interactivity.

SSR renders your appโ€™s HTML on the server before sending it to the browser, improving performance and crawlability โ€” especially important for public-facing map apps, dashboards, or location-based services.

๐Ÿงช Nuxt Playground โ€‹

To help you get started, we've built a dedicated Nuxt playground that demonstrates SSR integration with vue-leaflet.

๐Ÿ”ง Local Setup โ€‹

bash
git clone https://github.com/Maxel01/vue-leaflet.git
cd vue-leaflet/playgrounds/nuxt-playground
pnpm install
pnpm dev

Visit http://localhost:3000 to explore SSR-powered map components in action.

๐Ÿ› ๏ธ SSR Integration Tips โ€‹

Here are some best practices to ensure smooth SSR integration:

  • โœ… Use client-only rendering for components that rely on browser-specific APIs (window, document, etc.)
  • โœ… Defer map rendering using lifecycle hooks like onMounted or Nuxtโ€™s <ClientOnly> wrapper
  • โœ… Avoid direct DOM manipulation inside setup() or onServerPrefetch()
  • โœ… Lazy-load heavy components to reduce initial server payload
  • โœ… Use dynamic imports for plugins or features that are not SSR-safe

๐Ÿ“ฆ Plugin Support โ€‹

Only Leaflet plugins that have been ported to v2 and wrapped using vue-leaflet-plugins are compatible with SSR.
If you need support for a specific plugin, feel free to open an issue and help shape the roadmap.

๐Ÿ“š Additional Resources โ€‹


Need help debugging SSR issues or want to contribute improvements? Join the discussion on GitHub and help grow the vue-leaflet ecosystem!