
Mapbox Maplibre Migration
- 935 installs
- 71 repo stars
- Updated August 4, 2026
- mapbox/mapbox-agent-skills
mapbox-maplibre-migration is a frontend migration skill that updates MapLibre GL JS code, styles, tokens, and configuration to Mapbox GL JS equivalents for developers moving to hosted Mapbox tiles and APIs.
About
mapbox-maplibre-migration is a Mapbox agent skill that migrates MapLibre GL JS projects to Mapbox GL JS, noting the APIs are roughly 95% identical for straightforward conversion. It covers replacing tokens, style URLs, and configuration while unlocking official support, Mapbox Studio styles, Geocoding, Directions, Isochrone, Matrix APIs, Globe view, 3D terrain, and hosted tiles. The guide highlights a free tier of 50,000 map loads per month and enterprise compliance and analytics options. Frontend developers reach for it when self-hosted MapLibre stacks need premium global coverage, SLAs, or Mapbox platform services without rewriting the entire map UI.
- 95% API compatibility between MapLibre GL JS and Mapbox GL JS
- Automated migration of package names, tokens, and style URLs
- Converts OSM/custom tiles to Mapbox premium tile sources
- Updates code for Mapbox Studio styles and integrated APIs
- Includes checklist for official support, SLAs, and enterprise features
Mapbox Maplibre Migration by the numbers
- 935 all-time installs (skills.sh)
- +31 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Ranked #409 of 2,245 Frontend Development skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mapbox/mapbox-agent-skills --skill mapbox-maplibre-migrationAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 935 |
|---|---|
| repo stars | ★ 71 |
| Security audit | 3 / 3 scanners passed |
| Last updated | August 4, 2026 |
| Repository | mapbox/mapbox-agent-skills ↗ |
How do you migrate MapLibre GL JS to Mapbox GL JS?
Automatically update MapLibre GL JS code, styles, tokens, and configuration to the Mapbox GL JS equivalent.
Who is it for?
Frontend developers with existing MapLibre GL JS apps who need Mapbox-hosted tiles, Studio styles, or Geocoding and Directions APIs.
Skip if: Greenfield map projects with no MapLibre codebase or teams committed to fully self-hosted tile infrastructure.
When should I use this skill?
The user asks to migrate from MapLibre to Mapbox, update map tokens/styles, or adopt Mapbox GL JS APIs and hosted tiles.
What you get
Updated Mapbox GL JS initialization code, style and token configuration, and migration notes for Mapbox platform APIs.
- Migrated Mapbox GL JS code
- Updated style and token config
- API migration checklist
By the numbers
- MapLibre GL JS and Mapbox GL JS APIs are ~95% identical
- Mapbox free tier includes 50,000 map loads per month
Files
MapLibre to Mapbox Migration Skill
Expert guidance for migrating from MapLibre GL JS to Mapbox GL JS. Covers the shared history, API compatibility, migration steps, and the advantages of Mapbox's platform.
Understanding the Fork
History
MapLibre GL JS is an open-source fork of Mapbox GL JS v1.13.0, created in December 2020 when Mapbox changed their license starting with v2.0.
Timeline:
- Pre-2020: Mapbox GL JS was open source (BSD license)
- Dec 2020: Mapbox GL JS v2.0 introduced proprietary license
- Dec 2020: Community forked v1.13 as MapLibre GL JS
- Present: Both libraries continue active development
Key Insight: The APIs are ~95% identical because MapLibre started as a Mapbox fork. Most code works in both with minimal changes, making migration straightforward.
Why Migrate to Mapbox?
Compelling reasons to choose Mapbox GL JS:
- Official Support & SLAs: Enterprise-grade support with guaranteed response times
- Superior Tile Quality: Best-in-class vector tiles with global coverage and frequent updates
- Better Satellite Imagery: High-resolution, up-to-date satellite and aerial imagery
- Rich Ecosystem: Seamless integration with Mapbox Studio, APIs, and services
- Advanced Features: Traffic-aware routing, turn-by-turn directions, premium datasets
- Geocoding & Search: World-class address search and place lookup
- Navigation SDK: Mobile navigation with real-time traffic
- No Tile Infrastructure: No need to host or maintain your own tile servers
- Regular Updates: Continuous improvements and new features
- Professional Services: Access to Mapbox solutions team for complex projects
Mapbox offers a generous free tier: 50,000 map loads/month, making it suitable for many applications without cost.
Quick Comparison
| Aspect | Mapbox GL JS | MapLibre GL JS |
|---|---|---|
| License | Proprietary (v2+) | BSD 3-Clause (Open Source) |
| Support | Official commercial support | Community support |
| Tiles | Premium Mapbox vector tiles | OSM or custom tile sources |
| Satellite | High-quality global imagery | Requires custom source |
| Token | Required (access token) | Optional (depends on tile source) |
| APIs | Full Mapbox ecosystem | Requires third-party services |
| Studio | Full integration | No native integration |
| 3D Terrain | Built-in with premium data | Available (requires data source) |
| Globe View | v2.9+ | v3.0+ |
| API Compatibility | ~95% compatible with MapLibre | ~95% compatible with Mapbox |
| Bundle Size | ~500KB | ~450KB |
| Setup Complexity | Easy (just add token) | Requires tile source setup |
Step-by-Step Migration
1. Create Mapbox Account
1. Sign up at mapbox.com 2. Get your access token from the account dashboard 3. Review pricing: Free tier includes 50,000 map loads/month 4. Note your token (starts with pk. for public tokens)
2. Update Package
# Remove MapLibre
npm uninstall maplibre-gl
# Install Mapbox
npm install mapbox-gl3. Update Imports
// Before (MapLibre)
import maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';
// After (Mapbox)
import mapboxgl from 'mapbox-gl';
import 'mapbox-gl/dist/mapbox-gl.css';Or with CDN:
<!-- Before (MapLibre) -->
<script src="https://unpkg.com/maplibre-gl@3.0.0/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/maplibre-gl@3.0.0/dist/maplibre-gl.css" rel="stylesheet" />
<!-- After (Mapbox) -->
<script src="https://api.mapbox.com/mapbox-gl-js/v3.0.0/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v3.0.0/mapbox-gl.css" rel="stylesheet" />4. Add Access Token
// Add this before map initialization
mapboxgl.accessToken = 'pk.your_mapbox_access_token';Token best practices:
- Use environment variables:
process.env.VITE_MAPBOX_TOKENorprocess.env.NEXT_PUBLIC_MAPBOX_TOKEN - Add URL restrictions in Mapbox dashboard for security
- Use public tokens (
pk.*) for client-side code - Never commit tokens to git (add to
.envand.gitignore) - Rotate tokens if compromised
See mapbox-token-security skill for comprehensive token security guidance.
5. Update Map Initialization
// Before (MapLibre)
const map = new maplibregl.Map({
container: 'map',
style: 'https://demotiles.maplibre.org/style.json', // or your custom style
center: [-122.4194, 37.7749],
zoom: 12
});
// After (Mapbox)
mapboxgl.accessToken = 'pk.your_mapbox_access_token';
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/standard', // Mapbox style
center: [-122.4194, 37.7749],
zoom: 12
});6. Update Style URL
Mapbox provides professionally designed, maintained styles:
// Mapbox built-in styles
style: 'mapbox://styles/mapbox/standard'; // Mapbox Standard (default)
style: 'mapbox://styles/mapbox/standard-satellite'; // Mapbox Standard Satellite
style: 'mapbox://styles/mapbox/streets-v12'; // Streets v12
style: 'mapbox://styles/mapbox/satellite-v9'; // Satellite imagery
style: 'mapbox://styles/mapbox/satellite-streets-v12'; // Hybrid
style: 'mapbox://styles/mapbox/outdoors-v12'; // Outdoor/recreation
style: 'mapbox://styles/mapbox/light-v11'; // Light theme
style: 'mapbox://styles/mapbox/dark-v11'; // Dark theme
style: 'mapbox://styles/mapbox/navigation-day-v1'; // Navigation (day)
style: 'mapbox://styles/mapbox/navigation-night-v1'; // Navigation (night)Custom styles: You can also create and use custom styles from Mapbox Studio:
style: 'mapbox://styles/your-username/your-style-id';7. Update All References
Replace all maplibregl references with mapboxgl:
// Markers
const marker = new mapboxgl.Marker() // was: maplibregl.Marker()
.setLngLat([-122.4194, 37.7749])
.setPopup(new mapboxgl.Popup().setText('San Francisco'))
.addTo(map);
// Controls
map.addControl(new mapboxgl.NavigationControl(), 'top-right');
map.addControl(new mapboxgl.GeolocateControl());
map.addControl(new mapboxgl.FullscreenControl());
map.addControl(new mapboxgl.ScaleControl());8. Update Plugins (If Used)
Some MapLibre plugins should be replaced with Mapbox versions:
| MapLibre Plugin | Mapbox Alternative |
|---|---|
@maplibre/maplibre-gl-geocoder | @mapbox/mapbox-gl-geocoder |
@maplibre/maplibre-gl-draw | @mapbox/mapbox-gl-draw |
maplibre-gl-compare | mapbox-gl-compare |
Example:
// Before (MapLibre)
import MaplibreGeocoder from '@maplibre/maplibre-gl-geocoder';
// After (Mapbox)
import MapboxGeocoder from '@mapbox/mapbox-gl-geocoder';
map.addControl(
new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
mapboxgl: mapboxgl
})
);9. Everything Else Stays the Same
All your map code, events, layers, and sources work identically:
// This code works EXACTLY THE SAME in both libraries
map.on('load', () => {
map.addSource('points', {
type: 'geojson',
data: geojsonData
});
map.addLayer({
id: 'points-layer',
type: 'circle',
source: 'points',
paint: {
'circle-radius': 8,
'circle-color': '#ff0000'
}
});
});
// Events work identically
map.on('click', 'points-layer', (e) => {
console.log(e.features[0].properties);
});
// All map methods work the same
map.setCenter([lng, lat]);
map.setZoom(12);
map.fitBounds(bounds);
map.flyTo({ center: [lng, lat], zoom: 14 });What Changes: Summary
Must change:
- Package name (
maplibre-gl->mapbox-gl) - Import statements
- Add
mapboxgl.accessTokenconfiguration - Style URL (switch to
mapbox://styles) - Plugin packages (if used)
Stays exactly the same:
- All map methods (
setCenter,setZoom,fitBounds,flyTo, etc.) - All event handling (
map.on('click'),map.on('load'), etc.) - Marker/Popup APIs (100% compatible)
- Layer/source APIs (100% compatible)
- GeoJSON handling
- Custom styling and expressions
- Controls (Navigation, Geolocate, Scale, etc.)
Common Migration Issues
Issue 1: Token Not Set
Problem:
// Error: "A valid Mapbox access token is required to use Mapbox GL"
const map = new mapboxgl.Map({...});Solution:
// Set token BEFORE creating map
mapboxgl.accessToken = 'pk.your_token';
const map = new mapboxgl.Map({...});Issue 2: Token in Git
Problem:
// Token hardcoded in source
mapboxgl.accessToken = 'pk.eyJ1Ijoi...';Solution:
// Use environment variables
mapboxgl.accessToken = process.env.VITE_MAPBOX_TOKEN;
// Add to .env file (not committed to git)
VITE_MAPBOX_TOKEN=pk.your_token
// Add .env to .gitignore
echo ".env" >> .gitignoreIssue 3: Wrong Style URL Format
Problem:
// MapLibre-style URL won't work optimally
style: 'https://demotiles.maplibre.org/style.json';Solution:
// Use Mapbox style URL for better performance and features
style: 'mapbox://styles/mapbox/streets-v12';Issue 4: Plugin Compatibility
Problem:
// MapLibre plugin won't work
import MaplibreGeocoder from '@maplibre/maplibre-gl-geocoder';Solution:
// Use Mapbox plugin
import MapboxGeocoder from '@mapbox/mapbox-gl-geocoder';Important: This applies to ALL MapLibre plugins, not just the geocoder. Any@maplibre/*ormaplibre-gl-*plugin must be replaced with its Mapbox equivalent. Check the Mapbox ecosystem for Mapbox-specific versions of every plugin you use (see Step 8 above for the full mapping table).
Issue 5: CDN URLs
Problem:
// Wrong CDN
<script src="https://unpkg.com/maplibre-gl@3.0.0/dist/maplibre-gl.js"></script>Solution:
// Use Mapbox CDN
<script src='https://api.mapbox.com/mapbox-gl-js/v3.0.0/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v3.0.0/mapbox-gl.css' rel='stylesheet' />Migration Checklist
- [ ] Create Mapbox account and get access token
- [ ] Update package:
npm install mapbox-gl(remove maplibre-gl) - [ ] Update imports:
maplibre-gl->mapbox-gl - [ ] Update CSS imports:
maplibre-gl.css->mapbox-gl.css - [ ] Add token: Set
mapboxgl.accessToken = 'pk.xxx' - [ ] Use environment variables: Store token in
.env - [ ] Update style URL: Change to
mapbox://styles/mapbox/streets-v12 - [ ] Update all references: Replace
maplibregl.withmapboxgl. - [ ] Update plugins: Install Mapbox versions of plugins (if used)
- [ ] Configure token security: Add URL restrictions in dashboard
- [ ] Test all functionality: Verify map loads, interactions work
- [ ] Set up billing alerts: Monitor usage in Mapbox dashboard
- [ ] Update documentation: Document token setup for team
- [ ] Add .env to .gitignore: Ensure tokens not committed
Quick Reference
Key Differences Summary
| What | MapLibre | Mapbox |
|---|---|---|
| Package | maplibre-gl | mapbox-gl |
| Import | import maplibregl from 'maplibre-gl' | import mapboxgl from 'mapbox-gl' |
| Token | Optional (depends on tiles) | Required: mapboxgl.accessToken = 'pk.xxx' |
| Style | Custom URL or OSM tiles | mapbox://styles/mapbox/streets-v12 |
| License | BSD (Open Source) | Proprietary (v2+) |
| Support | Community | Official commercial support |
| Tiles | Requires tile source | Premium Mapbox tiles included |
| APIs | Third-party | Full Mapbox API ecosystem |
| API | ~95% compatible | ~95% compatible |
Bottom line: Migration is easy because APIs are nearly identical. Main changes are packaging, token setup, and style URLs. The result is access to Mapbox's premium tiles, ecosystem, and support.
Integration with Other Skills
Related skills:
- mapbox-web-integration-patterns: Framework-specific patterns (React, Vue, Svelte, Angular)
- mapbox-web-performance-patterns: Performance optimization techniques
- mapbox-token-security: Comprehensive token security best practices
- mapbox-google-maps-migration: Migrate from Google Maps to Mapbox
Resources
Mapbox GL JS:
Migration Support:
Reference Files
For detailed information on specific topics, load these reference files:
- `references/api-compatibility.md` -- Full list of 100% compatible APIs + side-by-side migration example
- `references/exclusive-features.md` -- Mapbox-exclusive features (APIs, Studio, Advanced) + React/Vue framework examples
- `references/why-mapbox.md` -- Why Choose Mapbox (Production, Dev Teams, Business) + Performance Comparison
MapLibre to Mapbox Migration Guide
Quick reference for migrating from MapLibre GL JS to Mapbox GL JS. APIs are ~95% identical - migration is straightforward.
Why Migrate to Mapbox?
Key advantages:
- ✅ Official support and SLAs
- ✅ Premium global tile coverage (streets, satellite, terrain)
- ✅ Mapbox APIs (Geocoding, Directions, Isochrone, Matrix)
- ✅ Mapbox Studio for custom styles (no coding required)
- ✅ Advanced features (Globe view, 3D terrain, better satellite)
- ✅ No infrastructure management (hosted tiles)
- ✅ Predictable costs, free tier: 50,000 map loads/month
- ✅ Enterprise features (compliance, analytics, support)
Migration Overview
| Aspect | MapLibre GL JS (Current) | Mapbox GL JS (Target) |
|---|---|---|
| Package | maplibre-gl | mapbox-gl |
| Token | Optional | Required (pk.\*) |
| Styles | Custom URL / OSM | mapbox://styles/... |
| Tiles | OSM / Custom | Mapbox premium tiles |
| Support | Community | Official + SLA |
| APIs | Separate | Integrated ecosystem |
| API Compatibility | ~95% identical | ~95% identical |
Key insight: Most of your code stays the same. Only packaging and configuration changes.
Step-by-Step Migration
1. Get Mapbox Access Token
# Sign up at mapbox.com
# Get token from account dashboard
# Free tier: 50,000 map loads/month2. Update Package
npm uninstall maplibre-gl
npm install mapbox-gl3. Update Imports
// Before (MapLibre)
import maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';
// After (Mapbox)
import mapboxgl from 'mapbox-gl';
import 'mapbox-gl/dist/mapbox-gl.css';4. Add Access Token
// Required for Mapbox
mapboxgl.accessToken = 'pk.your_mapbox_token';
// Best practice: Use environment variables
mapboxgl.accessToken = process.env.NEXT_PUBLIC_MAPBOX_TOKEN;5. Update Map Initialization
// Before (MapLibre with OSM tiles)
const map = new maplibregl.Map({
container: 'map',
style: 'https://demotiles.maplibre.org/style.json',
center: [-122.4194, 37.7749],
zoom: 12
});
// After (Mapbox with premium tiles)
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v12', // Or any Mapbox style
center: [-122.4194, 37.7749],
zoom: 12
});6. Everything Else Stays the Same!
// All these work identically:
map.setCenter([lng, lat]);
map.setZoom(zoom);
map.fitBounds(bounds);
map.on('click', handler);
new mapboxgl.Marker().setLngLat([lng, lat]).addTo(map);
new mapboxgl.Popup().setHTML(html).addTo(map);
map.addSource(id, source);
map.addLayer(layer);Mapbox Style Options
Pre-built styles:
'mapbox://styles/mapbox/standard'; // Mapbox Standard
'mapbox://styles/mapbox/standard-satellite'; // Mapbox Standard Satellite
'mapbox://styles/mapbox/streets-v12'; // Streets v12
'mapbox://styles/mapbox/outdoors-v12'; // Hiking/outdoor
'mapbox://styles/mapbox/light-v11'; // Minimal light
'mapbox://styles/mapbox/dark-v11'; // Minimal dark
'mapbox://styles/mapbox/satellite-v9'; // Satellite imagery
'mapbox://styles/mapbox/satellite-streets-v12'; // Satellite + labels
'mapbox://styles/mapbox/navigation-day-v1'; // Turn-by-turn navigationCustom styles:
- Create in Mapbox Studio (visual editor)
- Reference as
'mapbox://styles/your-username/style-id'
Plugin Migration
| MapLibre Plugin | Mapbox Plugin |
|---|---|
@maplibre/maplibre-gl-geocoder | @mapbox/mapbox-gl-geocoder |
@maplibre/maplibre-gl-draw | @mapbox/mapbox-gl-draw |
maplibre-gl-compare | mapbox-gl-compare |
Note: Most Mapbox plugins work directly, no alternatives needed.
API Compatibility (95%+)
100% Compatible APIs:
- Map methods (all setters/getters)
- Event handling
- Markers and Popups
- Sources and Layers
- Controls
- GeoJSON handling
- Camera animations
- Feature state
Only differences:
- Package name (
maplibre-glvsmapbox-gl) - Style URL format (custom vs
mapbox://) - Token requirement (optional vs required)
- Some plugins need Mapbox versions
Common Issues
Issue: Missing Token
// ❌ Forgot to set token
const map = new mapboxgl.Map({...}); // Error!
// ✅ Set token first
mapboxgl.accessToken = 'pk.your_token';
const map = new mapboxgl.Map({...});Issue: Wrong Style Format
// ❌ Using OSM/custom URL
style: 'https://demotiles.maplibre.org/style.json'; // Won't load Mapbox tiles
// ✅ Use Mapbox style URL
style: 'mapbox://styles/mapbox/streets-v12';Issue: Plugin Compatibility
// ❌ Using MapLibre plugin with Mapbox
import MaplibreGeocoder from '@maplibre/maplibre-gl-geocoder';
// ✅ Use Mapbox plugin
import MapboxGeocoder from '@mapbox/mapbox-gl-geocoder';Testing Checklist
✅ Map initializes without errors ✅ Tiles load correctly (Mapbox tiles, not OSM) ✅ Access token configured ✅ Markers/popups display properly ✅ Events fire as expected ✅ Custom layers render correctly ✅ Plugins work (if using Mapbox versions) ✅ No console errors ✅ Performance same or better
Token Security
Best practices:
// ✅ Use environment variables
mapboxgl.accessToken = process.env.NEXT_PUBLIC_MAPBOX_TOKEN;
// ✅ Add URL restrictions in Mapbox dashboard
// Only allow your domains
// ✅ Never commit tokens
// Add .env to .gitignore
// ✅ Use public tokens (pk.*) for client-side
// Never expose secret tokens (sk.*)Mapbox Ecosystem Benefits
After migration, you gain access to:
Mapbox APIs:
- Geocoding API (forward/reverse)
- Directions API (routing, turn-by-turn)
- Isochrone API (time/distance polygons)
- Matrix API (distance matrices)
- Tilequery API (feature lookup)
Mapbox Studio:
- Visual style editor (no coding)
- Dataset editor
- Tileset management
- Style publishing
Advanced Features:
- Globe view (3D Earth)
- 3D terrain with real elevations
- Premium satellite imagery
- Traffic-aware routing
- Real-time updates
Performance Notes
Mapbox tiles are optimized for:
- Fast loading (global CDN)
- Smaller file sizes (vector tiles)
- Better caching
- Consistent quality worldwide
Expected performance:
- Similar or better rendering speed
- Potentially faster tile loading (Mapbox CDN)
- Same memory usage
- Identical frame rates
Migration Timeline
Typical migration: 1-2 hours
1. Setup (15 min): Get token, update packages 2. Code changes (30 min): Update imports, add token, change style URL 3. Testing (30 min): Verify all features work 4. Deployment (15 min): Deploy and monitor
For large apps: May take 1-2 days including QA
Support & Resources
After migration:
- Official Mapbox support (for paid plans)
- Extensive documentation
- Code examples
- Community forums
- Enterprise SLAs (for enterprise plans)
Quick Decision: Should I Migrate?
Migrate to Mapbox if:
- ✅ Want official support
- ✅ Need Mapbox APIs (Geocoding, Directions)
- ✅ Want better tile quality/coverage
- ✅ Prefer no infrastructure management
- ✅ Need enterprise features
- ✅ Want Mapbox Studio for styling
- ✅ Building production applications
Free tier (50K loads/month) is often sufficient for:
- Small-medium websites
- Internal tools
- MVPs and prototypes
- Many business applications
Migration is Low Risk
✅ ~95% API compatibility = minimal code changes ✅ Quick migration (1-2 hours typical) ✅ Free tier available for testing ✅ Easy to rollback if needed ✅ No data loss (just configuration changes)
{
"skill_name": "mapbox-maplibre-migration",
"evals": [
{
"id": 1,
"prompt": "I'm migrating a MapLibre GL JS web app to Mapbox GL JS. My app uses custom GeoJSON sources, symbol layers, `fitBounds`, `flyTo`, event handlers, and popups. How much code will I need to change?",
"expectations": [
"Reassures the migration is minimal — the APIs are ~95% compatible since MapLibre is a fork of Mapbox GL JS",
"Lists the actual changes needed: npm install mapbox-gl / remove maplibre-gl, update import, add mapboxgl.accessToken, update style URL",
"States that GeoJSON sources, symbol layers, fitBounds, flyTo, events, and popups all work identically — no changes needed for these",
"Explains that all maplibregl. references must be replaced with mapboxgl."
]
},
{
"id": 2,
"prompt": "I migrated my app from MapLibre to Mapbox GL JS by swapping the package and changing the import. Now I get the error: 'A valid Mapbox access token is required to use Mapbox GL JS. Please set mapboxgl.accessToken before creating a map.' Where does the token go?",
"expectations": [
"Token must be set as mapboxgl.accessToken = 'pk.xxx' BEFORE calling new mapboxgl.Map()",
"Shows the correct pattern: set accessToken at the module level, then create the map",
"Advises storing the token in an environment variable (e.g., process.env.VITE_MAPBOX_TOKEN) and not hardcoding it",
"Notes the token is NOT passed as a constructor option to the Map — it's a module-level property"
]
},
{
"id": 3,
"prompt": "After migrating from MapLibre to Mapbox GL JS, my geocoder plugin broke. I was using `@maplibre/maplibre-gl-geocoder`. What do I need to do?",
"expectations": [
"MapLibre plugins are NOT compatible with Mapbox GL JS — must use the Mapbox equivalent",
"Install the Mapbox geocoder: @mapbox/mapbox-gl-geocoder",
"Update the import from MaplibreGeocoder to MapboxGeocoder",
"Notes that other MapLibre plugins also need Mapbox equivalents — check Mapbox ecosystem for Mapbox-specific versions"
]
}
]
}
API Compatibility Matrix
100% Compatible APIs
These work identically in both libraries:
// Map methods
map.setCenter([lng, lat]);
map.setZoom(zoom);
map.fitBounds(bounds);
map.panTo([lng, lat]);
map.flyTo({ center, zoom });
map.getCenter();
map.getZoom();
map.getBounds();
map.resize();
// Events
map.on('load', callback);
map.on('click', callback);
map.on('move', callback);
map.on('zoom', callback);
map.on('rotate', callback);
// Markers
new mapboxgl.Marker();
marker.setLngLat([lng, lat]);
marker.setPopup(popup);
marker.addTo(map);
marker.remove();
marker.setDraggable(true);
// Popups
new mapboxgl.Popup();
popup.setLngLat([lng, lat]);
popup.setHTML(html);
popup.setText(text);
popup.addTo(map);
// Sources & Layers
map.addSource(id, source);
map.removeSource(id);
map.addLayer(layer);
map.removeLayer(id);
map.getSource(id);
map.getLayer(id);
// Styling
map.setPaintProperty(layerId, property, value);
map.setLayoutProperty(layerId, property, value);
map.setFilter(layerId, filter);
// Controls
map.addControl(control, position);
new mapboxgl.NavigationControl();
new mapboxgl.GeolocateControl();
new mapboxgl.FullscreenControl();
new mapboxgl.ScaleControl();Side-by-Side Example
MapLibre GL JS (Before)
import maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';
// No token needed for OSM tiles
const map = new maplibregl.Map({
container: 'map',
style: 'https://demotiles.maplibre.org/style.json',
center: [-122.4194, 37.7749],
zoom: 12
});
map.on('load', () => {
new maplibregl.Marker()
.setLngLat([-122.4194, 37.7749])
.setPopup(new maplibregl.Popup().setText('San Francisco'))
.addTo(map);
});Mapbox GL JS (After)
import mapboxgl from 'mapbox-gl';
import 'mapbox-gl/dist/mapbox-gl.css';
// Add your Mapbox token
mapboxgl.accessToken = 'pk.your_mapbox_access_token';
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v12',
center: [-122.4194, 37.7749],
zoom: 12
});
map.on('load', () => {
new mapboxgl.Marker()
.setLngLat([-122.4194, 37.7749])
.setPopup(new mapboxgl.Popup().setText('San Francisco'))
.addTo(map);
});What's different: Package, import, token, and style URL. Everything else is identical.
Mapbox-Exclusive Features
After migration, you gain access to these Mapbox-only features:
Premium Vector Tiles
- Streets: Comprehensive road network with names, shields, and routing data
- Satellite: High-resolution global imagery updated regularly
- Terrain: Elevation data with hillshading and 3D terrain
- Traffic: Real-time traffic data (with Navigation SDK)
Mapbox APIs
Use these APIs alongside your map for enhanced functionality:
// Geocoding API - Convert addresses to coordinates
const response = await fetch(
`https://api.mapbox.com/search/geocode/v6/forward?q=San+Francisco&access_token=${mapboxgl.accessToken}`
);
// Directions API - Get turn-by-turn directions
const directions = await fetch(
`https://api.mapbox.com/directions/v5/mapbox/driving/-122.42,37.78;-122.45,37.76?access_token=${mapboxgl.accessToken}`
);
// Isochrone API - Calculate travel time polygons
const isochrone = await fetch(
`https://api.mapbox.com/isochrone/v1/mapbox/driving/-122.42,37.78?contours_minutes=5,10,15&access_token=${mapboxgl.accessToken}`
);Mapbox Studio
- Visual style editor with live preview
- Dataset management and editing
- Tilesets with custom data upload
- Collaborative team features
- Style versioning and publishing
Advanced Features (v2.9+)
- Globe projection: Seamless transition from globe to Mercator
- 3D buildings: Extrusion with real building footprints
- Custom terrain: Use your own DEM sources
- Sky layer: Realistic atmospheric rendering
Framework Integration
Migration works identically across all frameworks. See mapbox-web-integration-patterns skill for detailed React, Vue, Svelte, Angular patterns.
React Example
import { useRef, useEffect } from 'react';
import mapboxgl from 'mapbox-gl';
import 'mapbox-gl/dist/mapbox-gl.css';
// Set token once (can be in app initialization)
mapboxgl.accessToken = process.env.REACT_APP_MAPBOX_TOKEN;
function MapComponent() {
const mapRef = useRef(null);
const mapContainerRef = useRef(null);
useEffect(() => {
mapRef.current = new mapboxgl.Map({
container: mapContainerRef.current,
style: 'mapbox://styles/mapbox/streets-v12',
center: [-122.4194, 37.7749],
zoom: 12
});
return () => {
mapRef.current.remove();
};
}, []);
return <div ref={mapContainerRef} style={{ height: '100vh' }} />;
}Just replace maplibregl with mapboxgl and update token/style - everything else is identical!
Vue Example
<template>
<div ref="mapContainer" class="map-container"></div>
</template>
<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import mapboxgl from 'mapbox-gl';
import 'mapbox-gl/dist/mapbox-gl.css';
mapboxgl.accessToken = import.meta.env.VITE_MAPBOX_TOKEN;
const mapContainer = ref(null);
let map = null;
onMounted(() => {
map = new mapboxgl.Map({
container: mapContainer.value,
style: 'mapbox://styles/mapbox/streets-v12',
center: [-122.4194, 37.7749],
zoom: 12
});
});
onUnmounted(() => {
map?.remove();
});
</script>
<style scoped>
.map-container {
height: 100vh;
}
</style>Why Choose Mapbox
For Production Applications
Reliability & Support:
- 99.9% uptime SLA for enterprise customers
- 24/7 support with guaranteed response times
- Dedicated solutions engineers for complex projects
- Regular platform updates and improvements
Performance:
- Global CDN for fast tile delivery
- Optimized vector tiles for minimal bandwidth
- Automatic scaling for traffic spikes
- WebGL-accelerated rendering
Features:
- Professional cartography and design
- Regular map data updates
- Traffic and routing data
- Premium satellite imagery
- 3D terrain and buildings
For Development Teams
Developer Experience:
- Comprehensive documentation with examples
- Active community and forums
- Regular SDK updates
- TypeScript support (via
@types/mapbox-gl) - Extensive example gallery
Ecosystem Integration:
- Seamless Studio integration
- API consistency across services
- Mobile SDKs (iOS, Android, React Native)
- Unity and Unreal Engine plugins
- Analytics and monitoring tools
For Business
Predictable Costs:
- Clear, usage-based pricing
- Free tier for development and small apps
- No infrastructure costs
- Scalable pricing for growth
Compliance & Security:
- SOC 2 Type II certified
- GDPR compliant
- Enterprise security features
- Audit logs and monitoring
No Infrastructure Burden:
- No tile servers to maintain
- No storage or bandwidth concerns
- No update management
- Focus on your application, not infrastructure
Performance Comparison
Both libraries have similar rendering performance as they share the same core codebase:
| Metric | Mapbox GL JS | MapLibre GL JS |
|---|---|---|
| Bundle size | ~500KB | ~450KB |
| Initial load | Similar | Similar |
| Rendering | WebGL-based | WebGL-based |
| Memory usage | Similar | Similar |
| Tile loading | Faster (CDN + optimized tiles) | Depends on tile source |
Key insight: Choose based on features, support, and tile quality, not rendering performance. Mapbox's advantage is in tile delivery speed, data quality, and ecosystem integration.
Related skills
How it compares
Use mapbox-maplibre-migration when moving from self-hosted MapLibre; stay on MapLibre skills if you require fully self-hosted tiles with no Mapbox billing.
FAQ
How similar are MapLibre and Mapbox GL JS APIs?
mapbox-maplibre-migration states MapLibre GL JS and Mapbox GL JS APIs are roughly 95% identical, making migration mostly a token, style URL, and configuration update rather than a full rewrite.
What Mapbox free tier limit applies after migration?
mapbox-maplibre-migration notes Mapbox hosted tiles include a free tier of 50,000 map loads per month alongside premium global coverage and Mapbox Studio style support.
Is Mapbox Maplibre Migration safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.