maplibre/maplibre-mapbox-migration
Migrating from Mapbox GL JS to MapLibre GL JS — package and import changes, removing the access token, choosing tile sources, plugin equivalents, and what you gain or give up. Use when moving an existing Mapbox map to MapLibre.
npx skills add https://github.com/maplibre/maplibre-agent-skills --skill maplibre-mapbox-migration
This skill guides you through migrating an application from Mapbox GL JS to MapLibre GL JS. The two libraries share a common ancestry (MapLibre forked from Mapbox GL JS v1.13 in December 2020), so the API is largely the same. The main changes are: swap the package, replace the namespace, remove the Mapbox access token, and choose a new tile source (MapLibre does not use mapbox:// styles).
Primary reference: MapLibre official Mapbox migration guide.
Common reasons teams switch from Mapbox to MapLibre:
What you give up: Mapbox Studio integration, Mapbox-hosted tiles and styles, Mapbox Search/Directions/Geocoding APIs, official Mapbox support.
npm install maplibre-gl
// Before (Mapbox)
import mapboxgl from 'mapbox-gl';
import 'mapbox-gl/dist/mapbox-gl.css';
// After (MapLibre)
import maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';
CDN: Replace Mapbox script/link with MapLibre:
https://api.mapbox.com/mapbox-gl-js/v*.*.*/mapbox-gl.js → https://unpkg.com/maplibre-gl@*.*.*/dist/maplibre-gl.jsReplace all mapboxgl with maplibregl (and mapbox-gl with maplibre-gl in package names or paths). Examples:
// Before (Mapbox)
const map = new mapboxgl.Map({ ... });
new mapboxgl.Marker().setLngLat([lng, lat]).addTo(map);
map.addControl(new mapboxgl.NavigationControl());
// After (MapLibre)
const map = new maplibregl.Map({ ... });
new maplibregl.Marker().setLngLat([lng, lat]).addTo(map);
map.addControl(new maplibregl.NavigationControl());
CSS class names: If you style controls or UI by class, rename mapboxgl-ctrl to maplibregl-ctrl (and similar prefixes).
MapLibre does not use mapboxgl.accessToken. Remove any line that sets it.
Tile and API keys (e.g. for hosted tile services or geocoding) are configured per service, not on the map instance. See maplibre-tile-sources for providers that need a key.
Mapbox styles (mapbox://styles/...) will not work in MapLibre. You must point the map to a style that uses non-Mapbox tile sources, sprites, and glyphs.
The simplest option is to use a style URL that does not require an API key, like OpenFreeMap. OpenFreeMap is community-funded and free to use with no API key; if your app depends on it in production, consider donating to support the project. Once you have tested and verified your migration works, you can explore the many available options (see awesome-maplibre or MapLibre Tile Sources for further suggestions).
Example:
// Before (Mapbox)
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v12',
center: [-122.42, 37.78],
zoom: 12
});
// After (MapLibre)
const map = new maplibregl.Map({
container: 'map',
style: 'https://tiles.openfreemap.org/styles/liberty', // or your chosen style
center: [-122.42, 37.78],
zoom: 12
});
From there, you can install the MapLibre Style Specification & Utilities to validate and debug styles:
npm install @maplibre/maplibre-style-spec
Custom Mapbox styles: If you designed a style in Mapbox Studio, you cannot load it directly in MapLibre. Export the style JSON and replace Mapbox source URLs with URLs for your chosen tile source. Your styles will not render unless and until you adjust all references to the Mapbox tile schema to match the tile schema of your new tile source. In addition to updating source URLs, this means adapting the id, source, and source-layer properties in your style JSON to match the new source and layer names.
Most properties in Mapbox styles are compatible with MapLibre. Check the MapLibre Style Specification for details on supported properties and types. You can use Maputnik, MapLibre's style editor, to visually test and debug your style JSON, and MapLibre Style Spec CLI Tools to check for compatibility and other validation issues.
gl-style-validate style.json
Many Mapbox plugins work with MapLibre unchanged, and many have been forked or replaced with MapLibre-native versions. Where a MapLibre-native alternative exists, prefer it for long-term compatibility.
Check the User Interface Plugins, Geocoding & Search Plugins, and Map Rendering Plugins sections of awesome-maplibre to find compatible plugins and alternatives.
If your app calls Mapbox Geocoding, Directions, or other REST APIs, replace them with open or third-party services:
Usage policies and sustainability: These are open or community-funded services with terms that matter in production:
router.project-osrm.org) — Explicitly not for production; no SLA or uptime guarantee. Self-host or use a managed service (e.g. OpenRouteService, MapTiler Directions) for production apps.Update your code to use the new endpoints and response formats; the map layer and interaction code (e.g. adding a route line) stays the same with MapLibre.
Most of your map code does not change:
setCenter, setZoom, fitBounds, flyTo, getBounds, etc.map.on('load'), map.on('click', layerId, callback), etc.addSource, addLayer, setPaintProperty, setFilterSo after swapping the package, namespace, token, and style (and any plugins/APIs), the rest of your logic can stay as is.
mapbox-gl, install maplibre-glmapboxgl with maplibregl (and CSS classes mapboxgl- → maplibregl-)mapboxgl.accessTokenstyle to a non-Mapbox URL (hosted or your own style)These sources were used when creating this skill. You may want to involve contributors who maintain or have contributed to them:
mapbox-maplibre-migration skill (Mapbox repo) covers the reverse direction (MapLibre → Mapbox). Topic structure and comparison elements were adapted for this Mapbox → MapLibre skill. Copyright (c) Mapbox, Inc. for adapted portions.Take maplibre/maplibre-mapbox-migration from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference npm.
Without those the skill loads but fails at the first command.