npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@studiometa/ui-mapbox

v1.10.0

Published

Vanilla js-toolkit components to build Mapbox GL maps declaratively

Readme

@studiometa/ui-mapbox

NPM Version Downloads

Vanilla @studiometa/js-toolkit components to build Mapbox GL maps declaratively.

Installation

Install the package along with its mapbox-gl peer dependency:

npm install @studiometa/ui-mapbox mapbox-gl

The geocoder component relies on the optional @mapbox/mapbox-gl-geocoder peer dependency, install it only if you need it:

npm install @mapbox/mapbox-gl-geocoder

Usage

Register each component your page uses: each one registers independently and resolves its parent map on its own. mapbox-gl is heavy (~230 kB gzipped), so the recommended default is to lazy-register each component with js-toolkit's importWhen* helpers and the per-component subpaths (each subpath's default export is the component class), keeping the dependency out of your main bundle until a map is actually on the page:

import { registerComponents, importWhenVisible } from '@studiometa/js-toolkit';

// Register only the components your page uses; order doesn't matter.
registerComponents(
  importWhenVisible(() => import('@studiometa/ui-mapbox/MapboxMap'), 'MapboxMap'),
  importWhenVisible(() => import('@studiometa/ui-mapbox/MapboxMarker'), 'MapboxMarker'),
  importWhenVisible(() => import('@studiometa/ui-mapbox/MapboxPopup'), 'MapboxPopup'),
);

Other triggers are available too — importWhenIdle, importOnInteraction and importOnMediaQuery — see the importWhen* helper docs. Then author the map declaratively in your markup:

<div
  data-component="MapboxMap"
  data-option-access-token="pk.your-access-token"
  data-option-zoom="10"
  data-option-center="[2.3522, 48.8566]">
  <div data-ref="container" class="h-96 w-full"></div>

  <div hidden data-component="MapboxMarker" data-option-lng-lat="[2.3522, 48.8566]"></div>
</div>

If you do not need code-splitting, register eagerly instead — each component is exported by name from the package:

import { registerComponent } from '@studiometa/js-toolkit';
import { MapboxMap } from '@studiometa/ui-mapbox';

registerComponent(MapboxMap);

Do not forget to include the mapbox-gl stylesheet so the map renders correctly.

Providing mapbox-gl

By default the components resolve mapbox-gl (and the optional @mapbox/mapbox-gl-geocoder) with a lazy import() the first time a map is built, so the dependency stays out of your main bundle until it is needed. You never have to configure anything for the default to work — just keep mapbox-gl installed.

When you need to control which mapbox-gl the components use — a specific version, a self-hosted build (e.g. a same-origin worker under a strict CSP), or a module served from an import map or a CDN — inject your own instance once, before the components mount:

import mapboxgl from 'mapbox-gl';
import { provideMapboxGl, provideMapboxGeocoder } from '@studiometa/ui-mapbox';

provideMapboxGl(mapboxgl);

// Optional: inject the geocoder control constructor as well.
import MapboxGeocoder from '@mapbox/mapbox-gl-geocoder';
provideMapboxGeocoder(MapboxGeocoder);

Once provided, @studiometa/ui-mapbox never imports mapbox-gl by specifier — it uses the instance you handed it. resolveMapboxGl() / resolveMapboxGeocoder() are also exported if you want to trigger (and await) resolution yourself, for example to preload the module.

Heads up to ui.studiometa.dev for the full documentation.

Contributing

Please read the contribution docs.