Skip to content
Playground component

Leaflet map

SSR-safe map initialization with cleanup, icon fixes, and a lightweight default tile layer.

Preview

Leaflet map with safe lifecycle.

Initialized on the client with `onMount`, cleaned up on destroy, and configured with OpenStreetMap tiles.

SSR-safe setup

Leaflet runs only on the client, so the map initializes inside `onMount`.

Clean teardown

The map removes itself when the component unmounts to avoid retained listeners.

Next step

Add your own tiles and markers.

Switch to a custom tile provider and inject your data-driven markers on load.

Browse guides
Built as a personal SvelteKit 5 lab with Supabase auth. Guides, patterns, and a playground you can actually ship.
Command Palette
Search for a command to run