---
title: "Leaflet · Nuxt Scripts"
description: "Add lightweight, provider-agnostic interactive maps to Nuxt with lazy loading."
canonical_url: "https://scripts.nuxt.com/scripts/leaflet"
meta:
  "og:description": "Add lightweight, provider-agnostic interactive maps to Nuxt with lazy loading."
  "og:image": "https://scripts.nuxt.com/_og/s/o_4fa2c9ddf8213c45.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Leaflet · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_4fa2c9ddf8213c45.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Scripts**

# **Leaflet**

[Copy for LLMs](https://scripts.nuxt.com/scripts/leaflet.md)

[**Leaflet**](https://leafletjs.com/) is an open-source JavaScript library for interactive maps. It provides the map renderer and interaction model; you choose the tile provider, attribution, geocoding, and routing services separately.

Nuxt Scripts supports Leaflet 1.9.4 through the [`**useScriptLeaflet()**`](https://scripts.nuxt.com/scripts/leaflet/api/use-script-leaflet) composable and a small set of declarative components. First-party mode bundles the SDK by default, while Nuxt Scripts embeds the styles and marker images locally.

`**injectStyles**``boolean` = true

Inject the Leaflet 1.9.4 styles and default marker images when the script begins loading. Disable this when supplying your own Leaflet stylesheet.

## Setup

Install Leaflet's types, then enable the registry entry:

```bash
pnpm add -D @types/leaflet
```

nuxt.config.ts

```ts
export default defineNuxtConfig({
  scripts: {
    registry: {
      leaflet: { trigger: false },
    },
  },
})
```

## Quick Start

Leaflet does not include map imagery. This example explicitly chooses OpenStreetMap's standard tile service and keeps its required visible attribution.

```vue
<script setup lang="ts">
const center = ref<[number, number]>([-37.8136, 144.9631])
</script>

<template>
  <ScriptLeafletMap
    :center="center"
    :zoom="13"
    width="100%"
    :height="480"
    aria-label="Map of central Melbourne"
  >
    <ScriptLeafletTileLayer
      url="https://tile.openstreetmap.org/{z}/{x}/{y}.png"
      :options="{
        maxZoom: 19,
        attribution: '&copy; <a href=&quot;https://www.openstreetmap.org/copyright&quot;>OpenStreetMap contributors</a>',
      }"
    />

    <ScriptLeafletMarker
      :position="center"
      alt="Melbourne CBD"
    >
      <ScriptLeafletPopup>
        Melbourne CBD
      </ScriptLeafletPopup>
    </ScriptLeafletMarker>
  </ScriptLeafletMap>
</template>
```

The default `**visible**` trigger defers the Leaflet SDK and all tile requests until the map approaches the viewport. The component reserves its dimensions during SSR to avoid layout shift.

OpenStreetMap's public tile service has usage limits and no SLA. Read [**Tiles & Attribution**](https://scripts.nuxt.com/scripts/leaflet/guides/tiles-and-attribution) before choosing it for production.

**Real-world example:** [**Build a pickup locator**](https://scripts.nuxt.com/scripts/leaflet/guides/pickup-locator) with a keyboard-accessible store list, reactive selection, marker popups, error fallback content, and a GeoJSON delivery zone.

## Components

- [`**<ScriptLeafletMap>**`](https://scripts.nuxt.com/scripts/leaflet/api/script-leaflet-map) creates the map and controls lazy loading.
- [`**<ScriptLeafletTileLayer>**`](https://scripts.nuxt.com/scripts/leaflet/api/tile-layer) connects an explicit tile provider.
- [`**<ScriptLeafletMarker>**`](https://scripts.nuxt.com/scripts/leaflet/api/marker) adds accessible, reactive markers.
- [`**<ScriptLeafletPopup>**`](https://scripts.nuxt.com/scripts/leaflet/api/popup) binds slotted HTML to a marker or coordinate.
- [`**<ScriptLeafletGeoJson>**`](https://scripts.nuxt.com/scripts/leaflet/api/geojson) renders inline GeoJSON.

## Guides

- [**Pickup Locator**](https://scripts.nuxt.com/scripts/leaflet/guides/pickup-locator) builds a practical locator from markers, popups, and GeoJSON.
- [**Tiles & Attribution**](https://scripts.nuxt.com/scripts/leaflet/guides/tiles-and-attribution) explains where map imagery comes from and what production deployments need to consider.
- [**Performance & Accessibility**](https://scripts.nuxt.com/scripts/leaflet/guides/performance-and-accessibility) covers loading triggers, SSR sizing, fallback content, and decorative maps.

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/leaflet/index.md)

[Markdown For LLMs](https://scripts.nuxt.com/scripts/leaflet.md)

[**useScriptLeaflet** Use useScriptLeaflet() when you need direct access to the Leaflet namespace or are building your own map component.](https://scripts.nuxt.com/scripts/leaflet/api/use-script-leaflet) [**Lemon Squeezy** Load Lemon.js or turn checkout links into lazy overlay triggers.](https://scripts.nuxt.com/scripts/lemon-squeezy)

**On this page **

- [Setup](#setup)
- [Quick Start](#quick-start)
- [Components](#components)
- [Guides](#guides)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","description":"Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/scripts/leaflet#webpage","@type":"WebPage","description":"Add lightweight, provider-agnostic interactive maps to Nuxt with lazy loading.","name":"Leaflet","url":"https://scripts.nuxt.com/scripts/leaflet","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/leaflet#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/leaflet"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/scripts/leaflet#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Scripts","item":"https://scripts.nuxt.com/scripts","position":2},{"@type":"ListItem","name":"Leaflet","item":"https://scripts.nuxt.com/scripts/leaflet","position":3}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
