Wrap maplibre-gl in the official react-map-gl adapter for declarative React components. Drop in <Map> + <Source> + <Layer> and stay purely React, with no imperative DOM ref handling.
pnpm add maplibre-gl react-map-glimport 'maplibre-gl/dist/maplibre-gl.css';
import Map, { Source, Layer, NavigationControl } from 'react-map-gl/maplibre';
const MAP_STYLE = 'https://maps.guru/api/v1/styles/standard/light/style.json?key=YOUR_API_KEY';
export function CityMap() {
return (
<Map
initialViewState={{ longitude: 77.209, latitude: 28.6139, zoom: 11 }}
mapStyle={MAP_STYLE}
style={{ width: '100%', height: 480 }}
>
<NavigationControl position="top-right" />
<Source
id="places"
type="geojson"
data="https://maps.guru/api/v1/datasets/your-dataset/geojson?key=YOUR_API_KEY"
>
<Layer
id="places-fill"
type="circle"
paint={{
'circle-radius': 6,
'circle-color': '#e66200',
'circle-stroke-width': 2,
'circle-stroke-color': '#fcfaf6',
}}
/>
</Source>
</Map>
);
}
Free-tier generous enough for real production traffic. 50,000 tile requests/month , no credit card.
You can use maplibre-gl directly, but react-map-gl handles cleanup, viewport state, and re-renders for you. Most React teams ship faster with the wrapper.
Yes. Mark the map component with `"use client"` and dynamic-import it with `ssr:false` so the WebGL context never runs during SSR.
Pass the `?key=` query on the style URL. maplibre-gl forwards the same auth through to every tile, sprite, and glyph request automatically.
The vocabulary behind vector tiles, styles, and geocoding, in plain language.
Join developers worldwide who trust maps.guru for their mapping needs. Start free, no credit card required.