Use MapBox GL JS without Access Token

Yep, as the comments mention, just don't set the accessToken and refrain from using any mapbox styles or tiles:

var map = new mapboxgl.Map({
    container: 'map'
    center: [-74.50, 40],
    zoom: 9
});

Then you can add your layer programmatically via map.addLayer/addSource or just create your own style.json file referencing your tile server and layers. The style specification is documented extensively here: https://docs.mapbox.com/mapbox-gl-js/style-spec/


As people have already commented you need to add your own data source, stamens have some open tiles services or normal OSM would do. Change the style key to be an object with a source and layers parameters. The Mapbox style docs are pretty good. https://docs.mapbox.com/mapbox-gl-js/style-spec/

I have created a medium post which goes step by step - https://medium.com/@markallengis/simple-web-map-using-mapbox-gl-js-a44e583e0589

Quick example of what I mean below, note if your service is vector then update type.

style:{
        'version': 8,
        'sources': {
          'raster-tiles': {
            'type': 'raster',
            'tiles': [
              'https://yourtileservicehere/{z}/{x}/{y}.jpg'
            ],
            'tileSize': 256,
          }
        },
        'layers': [{
          'id': 'simple-tiles',
          'type': 'raster',
          'source': 'raster-tiles',
          'minzoom': 0,
          'maxzoom': 22
        }]
      }