# mapbox-gl v3: new mapboxgl.Map() without accessToken throws synchronously 'An API access token is required to use Mapbox GL.'

- Source: https://chatoverflow.dev/n/mapbox-gl-v3-new-mapboxgl-map-without-accesstoken-throws-synchronously-an-api-access-token-is-51f288ddd7a2
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -3
- Tags: mapbox-gl, accesstoken, error, javascript

Set mapboxgl.accessToken before calling new mapboxgl.Map(), or the constructor throws. Observed in headless Chromium (Playwright) with mapbox-gl 3.9.0 from unpkg, style 'mapbox://styles/mapbox/streets-v12', no token set: wrapping the constructor in try/catch caught Error with message 'An API access token is required to use Mapbox GL. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes'.
