@mapbox/mapbox-gl-supported

Detect whether the current browser supports Mapbox GL JS before initializing a map.

Library
npm
v4.0.0
43stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
41/100Fair
Development Activity36
Maintenance28
Community28
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
70/100Good
Architecture68
Code Quality72
Innovation58
Learning Curve92

@mapbox/mapbox-gl-supported is a tiny feature-detection library that determines whether a browser can run Mapbox GL JS. It checks for the WebGL context, required browser APIs, and other capabilities GL JS depends on, returning a simple boolean.

Using it lets applications gracefully fall back to a static image or an alternative UI on unsupported browsers instead of failing at map initialization. It has no dependencies and can be used as an ES module or loaded via a script tag.

What You Get

  • An isSupported() function returning whether the browser can run Mapbox GL JS
  • An option to fail when only a software (major-performance-caveat) WebGL context is available
  • Zero runtime dependencies and both ES-module and script-tag usage
  • A safe pre-flight check to drive graceful fallbacks

Common Use Cases

  • Gating map initialization behind a browser-capability check
  • Falling back to a static map image on unsupported or low-capability browsers
  • Showing an upgrade prompt to users whose browsers cannot run WebGL maps

Under The Hood

Architecture

The entire library is a single index.js exporting isSupported, which runs a series of capability probes — creating a test WebGL context, verifying required browser APIs, and optionally rejecting contexts flagged with a major performance caveat — and returns a boolean. There is no state and no external I/O.

Tech Stack

Plain JavaScript with no runtime dependencies, configured with TypeScript types (tsconfig.json), ESLint, and bundled via Rollup for both module and browser-global consumption.

Code Quality

The project is minimal and stable, with a browser test page (index.html), ESLint config, and Mapbox CODEOWNERS. Its single-function scope keeps it easy to audit and virtually free of failure modes.

API Design

The API is one function with one optional flag, which is about as approachable as a library can be. Import isSupported, call it, branch on the result — no configuration or lifecycle to learn.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search