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

@rijwind/sdk

v0.5.1

Published

Maps, geocoding, and routing SDK for the Rijwind API.

Readme

@rijwind/sdk

Maps, geocoding, and routing for the open web — one key, fully typed.

npm install @rijwind/sdk

Show a map

import { Map, MapStyle, config } from '@rijwind/sdk';
import '@rijwind/sdk/style.css';

config.apiKey = 'rw_live_…';

const map = new Map({
    container: 'map',
    style: MapStyle.STREETS, // STREETS · LIGHT · DARK · GRAYSCALE · WHITE · BLACK · OUTDOOR · SATELLITE · HYBRID
    center: [4.9041, 52.3676],
    zoom: 10,
});

STREETS is the default; LIGHT/DARK/GRAYSCALE/WHITE/BLACK are its colour variants. OUTDOOR adds hillshade + contour lines (see below). SATELLITE is satellite imagery (high-resolution aerial at street zoom wherever a country is covered — the Netherlands today, more as they are added; new countries come from the tile token's imagery list, no SDK update needed); HYBRID layers roads + labels over it. All ride the same map session — no extra cost for imagery, terrain, or contours.

Map extends MapLibre GL JS, so every MapLibre method, event, and option works unchanged — markers, popups, layers, the lot. On top, it opens a basemap tile session and keeps it fresh in the background, so a long-open map keeps working and you're billed once per map view, not per tile. You never handle signed URLs or tokens.

Tear-down is just MapLibre's remove() — the tile session is cleaned up with it:

map.remove();

Label language

Labels are in English by default (local name where there is no English one). Set language for another one (same fallback), or 'local' for native names, and switch at runtime with setLanguage — no flicker:

const map = new Map({ container: 'map', language: 'en' });
map.setLanguage('local'); // or 'en', 'de', 'fr', …

Supported codes are in SUPPORTED_LANGUAGES. Set a default for every map with config.language = 'local' (or any code). Static maps keep native names unless you pass language to staticMapUrl.

Outdoor map

MapStyle.OUTDOOR is Streets with shaded relief (hillshade) and elevation contour lines — for cycling, hiking, and the outdoors:

const map = new Map({ container: 'map', style: MapStyle.OUTDOOR, center: [6.87, 45.92], zoom: 12 });

Contours are generated in the browser from the terrain data and ride the same tile session, so they add no extra quota cost. You can also toggle the pieces on any style with the terrain (hillshade) and contours options, or raise tilted 3D terrain at runtime with map.setTerrain3D(true).

3D buildings

Where coverage exists (the Netherlands today; newly covered countries arrive through the tile token, without an SDK update), the map shows 3D buildings with real roof shapes — measured models, not extruded boxes. They're on by default on the Streets colour family (OUTDOOR goes without — pass buildings: true to opt in there): pan into a covered city at street zoom (14+) and tilt the map. Free within the map session.

// on by default — nothing to enable. Opt out:
const map = new Map({ container: 'map', buildings: false });

// or toggle / tune at runtime:
map.setBuildings(false);
map.setBuildings({ color: '#334155' });

The rendering module (three.js) loads lazily, only when the viewport actually reaches a covered country at street zoom — maps elsewhere pay zero bundle and render cost. Works together with tilted 3D terrain (setTerrain3D(true)) — the buildings ride on the terrain surface. The required "© building data" credit is added to the map automatically.

Live traffic

Show real-time traffic — congestion-coloured roads plus an incident / roadworks overlay — on top of any style:

const map = new Map({ container: 'map', center: [4.9, 52.37], zoom: 9, traffic: true });

// …or toggle it at runtime:
map.enableTraffic();               // all available countries
map.enableTraffic({ countries: ['NL'], incidents: false });
map.disableTraffic();

The geometry loads once; a small live-state file is polled about once a minute and joined onto the roads client-side (no flicker). Traffic adds 1 unit per map session — one charge no matter how long the map stays open, drawn from the same unit pool as everything else. The layer refreshes itself and pauses polling while the browser tab is hidden. Required data attributions are added to the map's attribution control automatically.

The 3D map (createMap(), below) has the same layer since 0.5.0: createMap({ …, traffic: true }), map.enableTraffic(options) (a promise there) and map.disableTraffic() — the same colours, options and layer ids.

Custom styles

Pass your own MapLibre style URL or object instead of a MapStyle. Anywhere the tile source should point at the basemap, use the {{TILE_URL}} placeholder — the SDK substitutes the live session for you:

const map = new Map({ container: 'map', style: 'https://example.com/my-style.json' });

3D maps (WebGPU) — preview

@rijwind/sdk/gl draws the map with rijwind-gl, Rijwind's own WebGPU map engine: a lit 3D world with terrain, 3D buildings, trees, sun and shadows. Browsers without WebGPU get the regular Map instead, automatically. Full guide: docs.rijwind.com/3d-maps.

import { createMap } from '@rijwind/sdk/gl';
import { MapStyle, config } from '@rijwind/sdk';
import '@rijwind/sdk/style.css'; // used by the fallback

config.apiKey = 'rw_live_…';
const { renderer, map } = await createMap({
    container: 'map',
    style: MapStyle.STREETS,
    center: [4.8926, 52.3731],
    zoom: 16,
    pitch: 60,
});
// renderer === 'rijwind-gl' where WebGPU runs, 'maplibre' everywhere else.
  • Same style names: every MapStyle (Streets/Light, Dark, Grayscale, White, Black, Outdoor, Satellite, Hybrid) has a 3D version. Switch with map.setStyle('dark') (a name, not a URL) — within the Streets family the change is usually instant (Dark fades in as night falls). As in MapLibre, setStyle drops your own sources, layers, images and feature state and fires style.load again (add your layers there); load fires once. Listeners, markers, popups and controls stay.
  • Same billing: one unit per map session, from the same unit pool. Every setStyle switch stays in that session; only a late fallback to the regular Map (below) opens a new one.
  • Labels: English by default with a local fallback, as on Map; language: 'local' for native names. At runtime: map.setStyle(name, { language: 'de' }) (null = native names) — a setStyle like any other, so your layers come back from style.load.
  • Fallback to the regular Map: a custom style, the MapLibre options hash, maxBounds, minPitch / maxPitch, transformRequest, a projection other than mercator, or engine: 'maplibre'. If the engine loses the GPU for good after it started, a regular Map takes its place in the same container and onFallback(map, reason) is called. engine: 'rijwind-gl' turns both off: start-up rejects instead of falling back, and a later GPU loss only fires error with fatal: true.
  • Download: the engine ships inside this package (dist/engine/, since 0.4.0), so you run exactly the version your lockfile pins and nothing is fetched as code at runtime. Your bundler gives it its own chunk (about 2 MB compressed), loaded only when createMap() runs in a browser that can use it. Sites with a CSP need script-src 'wasm-unsafe-eval', worker-src blob: and connect-src https://cdn.rijwind.com https://api.rijwind.com (map data).

Your MapLibre code runs on it as it is. Swap new Map(options) for (await createMap(options)).map and the rest of your code stays the same:

  • the options bounds + fitBoundsOptions, minZoom / maxZoom, the gesture switches (dragRotate: false, touchPitch: false, …, interactive, cooperativeGestures) and attributionControl (shown by default, { compact: true } honoured);
  • addSource / addLayer (GeoJSON — inline or by URL, generateId, clustering with getClusterExpansionZoom / getClusterChildren / getClusterLeaves — and layers in MapLibre's style format), setData, setPaintProperty, setLayoutProperty, setFilter, the basemap's own layers by id, addImage / loadImage for icon-image (hasImage / listImages include the style's own icons, as in MapLibre);
  • setFeatureState, queryRenderedFeatures, project / unproject, events (map.on('click', 'my-layer', …), style.load, idle, …);
  • camera methods (fitBounds, flyTo, getZoom, zoomIn, …), interaction handlers (map.touchZoomRotate.disableRotation()) and a MapLibre-shaped getStyle();
  • map.addControl(...), including maplibre-gl's own NavigationControl, GeolocateControl and FullscreenControl, and maplibre-gl's own Popup (tested with maplibre-gl 5.x).

Markers and popups: new map.Marker() / new map.Popup() work on both maps (the engine's own, or maplibre-gl's on the fallback Map).

TypeScript: map is a union of the two map types, and TypeScript can't call overloaded methods such as on on a union. Type it as MapLibreCompatibleMap (the API both share) to write the code once, and narrow on renderer for what only one map has:

import { createMap, type MapLibreCompatibleMap } from '@rijwind/sdk/gl';

const created = await createMap({ container: 'map', center: [4.9, 52.37], zoom: 12 });
const map: MapLibreCompatibleMap = created.map;
map.on('style.load', () => {
    // at start and after every setStyle, which drops your layers
    map.addSource('stops', { type: 'geojson', data: '/stops.geojson' });
    map.addLayer({ id: 'stops', type: 'circle', source: 'stops' });
});
map.on('click', 'stops', (e) => {
    new map.Popup().setLngLat(e.lngLat).setText('A stop').addTo(map);
});
if (created.renderer === 'rijwind-gl') await created.map.setStyle('dark');

What differs:

  • maplibre-gl's own Marker class and ScaleControl don't work on the engine map (use new map.Marker());
  • setLanguage, setBuildings and setTerrain3D are Map only — use setStyle(name, { language }) and map.setOption('objects3d', false) (hides buildings and trees);
  • custom layers are WebGPU (render(pass, args)), not WebGL — weather layers have a ready-made WebGPU version, see below;
  • labels are drawn in every script (Greek, Cyrillic, Thai, Chinese, Japanese, Korean, Hindi, …); Arabic and Hebrew are laid out right to left by the engine itself, no RTL plugin needed, so language: 'local' shows them where Map falls back to English;
  • the world is drawn once (no world copies when zoomed all the way out).

Not in the engine yet (use the regular Map, or engine: 'maplibre'): tile URL templates and TileJSON sources (a TileJSON url is accepted but draws nothing), image sources, heatmaps, line-gradient, fill-pattern, box zoom, keyboard navigation, querySourceFeatures (throws with a clear message); setTerrain / setSky / setLight / setProjection are ignored with a warning.

Weather layers

Vane weather layers on either map from createMap(): @rijwind/sdk/weather returns WebGPU layers for the 3D map and Vane's own (WebGL) for the standard map, with the same options and methods. @rijwind/vane is an optional peer dependency — install it next to the SDK.

import { createMap } from '@rijwind/sdk/gl';
import { weatherLayers } from '@rijwind/sdk/weather';
import { VaneDataset, TEMPERATURE_STOPS, TEMPERATURE_CLIM } from '@rijwind/vane';

const created = await createMap({ container: 'map', center: [5.3, 52.2], zoom: 6 });
const W = await weatherLayers(created);
const dataset = await VaneDataset.openLatest('https://…/knmi_harmonie_nl_latest.json');

const temperature = new W.ColormapLayer({
    id: 'temperature', dataset, variable: 'temperature',
    colormap: TEMPERATURE_STOPS, clim: TEMPERATURE_CLIM, opacity: 0.7,
});
created.map.addLayer(temperature);
temperature.setTimestep(3.5);                                    // between two forecast steps
created.map.addLayer(new W.ParticlesLayer({ id: 'wind', dataset })); // moving wind
created.map.addLayer(new W.ArrowsLayer({ id: 'arrows', dataset }));
new W.ContoursLayer({ id: 'isobars', dataset, variable: 'pressure_msl' }).addTo(created.map);
new W.ValuesLayer({ id: 'values', dataset, variable: 'temperature' }).addTo(created.map);

map.setLayoutProperty(id, 'visibility', 'none') hides a layer (a hidden particle layer stops animating). ParticlesLayer also takes a seed for a repeatable field.

Geocoding & routing

The same package exposes a typed REST client. In Node or any backend, import it from the light entry point (@rijwind/sdk/client) so no map library is pulled in:

import { createClient } from '@rijwind/sdk/client';

const rijwind = createClient({ apiKey: process.env.RIJWIND_API_KEY! });

// Forward geocode
const { data, error } = await rijwind.geocode.search({ q: 'Damrak 1, Amsterdam', limit: 5 });
if (!error) {
    for (const f of data.features) console.log(f.properties.name, f.geometry.coordinates);
}

In the browser you can use the same methods straight off the main entry:

import { createClient, config } from '@rijwind/sdk';
config.apiKey = 'rw_live_…';
const rijwind = createClient(); // picks up config.apiKey

Every method returns { data, error, response } — the same shape as openapi-fetch, which this wraps. data is typed against the success response; error against the error envelope.

Route

const { data } = await rijwind.route({
    locations: [
        { lat: 52.3676, lon: 4.9041 },
        { lat: 52.0907, lon: 5.1214 },
    ],
    costing: 'bicycle',
});

console.log(data?.trip.summary);        // { length, time, ... }
console.log(data?.trip.legs[0].shape);  // encoded polyline (1e-6 precision)

Isochrone

const { data } = await rijwind.isochrone({
    locations: [{ lat: 52.3676, lon: 4.9041 }],
    costing: 'bicycle',
    contours: [{ time: 5 }, { time: 10 }, { time: 15 }],
    polygons: true,
});

Map matching

Snap a noisy GPS trace to the road network. The trace is capped at 100 points (use encodedPolyline for longer traces).

const { data } = await rijwind.mapMatching({
    shape: [
        { lat: 52.3676, lon: 4.9041 },
        { lat: 52.3681, lon: 4.9052 },
        { lat: 52.3689, lon: 4.9067 },
    ],
    costing: 'bicycle',
});

console.log(data?.trip.legs[0].shape); // matched, snapped polyline

Optimized route

Find the optimal visiting order over multiple waypoints (the first and last stay fixed). Capped at 20 locations; billed N units per call.

const { data } = await rijwind.optimizedRoute({
    locations: [
        { lat: 52.3676, lon: 4.9041 }, // start
        { lat: 52.0907, lon: 5.1214 },
        { lat: 51.9244, lon: 4.4777 },
        { lat: 52.3676, lon: 4.9041 }, // end
    ],
    costing: 'auto',
});

Static maps

staticMapUrl(params) builds a URL for a server-rendered map image — drop it straight into an <img>. Pure string building (no network, no map library), so it works in Node and the browser, and is exported from both @rijwind/sdk and @rijwind/sdk/client.

import { staticMapUrl, config } from '@rijwind/sdk';
config.apiKey = 'rw_live_…';

const url = staticMapUrl({
    center: [4.9041, 52.3676],
    zoom: 12,
    size: [800, 500],
    style: 'light', // light | dark | grayscale | white | black
    hidpi: true, // @2x (High-DPI) — costs 2 units
    markers: [{ lon: 4.9041, lat: 52.3676, color: '#ff0000', size: 'l', label: 'A' }],
    circle: { radiusMeters: 1000, fillColor: '#0066ff', fillOpacity: 0.15 },
});
// <img src={url} width={800} height={500} alt="map" />

Instead of center + zoom, give a bbox: [minLon, minLat, maxLon, maxLat], or set auto: true to frame the overlays — the same three viewport modes as Mapbox and MapTiler. Add paths for polylines, format: 'jpg' | 'webp', padding, and attribution (a corner, or false). Billed 1 unit per image (2 for @2x), from the same pool as every other endpoint.

Configuration

config holds the defaults every Map and createClient falls back to:

import { config } from '@rijwind/sdk';

config.apiKey = 'rw_live_…';
config.baseUrl = 'https://api.rijwind.com'; // default; point at a local instance in dev
config.fetch = customFetch;                 // optional — inject retries, telemetry

Per-call options override the globals: new Map({ apiKey }), createClient({ apiKey, baseUrl }).

Tile tokens from your own server (tokenUrl, since 0.5.0)

A map normally asks /tiles/v1/token for its tile token with your API key. To keep the key off the page, give both new Map and createMap your own endpoint instead — one that calls /tiles/v1/token with the key on your server and passes the answer through:

const { map } = await createMap({
    container: 'map',
    tokenUrl: '/api/rijwind-tiles-token',        // no apiKey needed
    trafficTokenUrl: '/api/rijwind-traffic-token', // optional: the traffic grant, if it has its own endpoint
    terrainTileUrl: '/api/rijwind-terrain/{z}/{x}/{y}', // optional: contour lines on Outdoor
});

The map fetches tokenUrl with a plain GET and no Authorization header (cookies only to your own origin), appending session= (and traffic= when the traffic layer asks for its grant, unless trafficTokenUrl is set). An endpoint on another origin must authenticate the request by its URL (a signed URL, say) and allow it with CORS. Billing is unchanged: your server's call to /tiles/v1/token bills the map session.

setStyle(MapStyle.DARK) now works on both maps createMap returns: the standard map (the 3D map's fallback) loads the hosted style in the same tile session — label language, Outdoor's hillshade and contours, buildings and traffic included — and the 3D map takes the MapStyle as it takes setStyle('dark'). The 3D map also has the standard map's setLanguage and setBuildings, so code that switches the language or hides the buildings runs on either map.

Entry points

| Import | Contains | Pulls in MapLibre? | | --- | --- | --- | | @rijwind/sdk | Map, MapStyle, config, REST client + types | yes (browser) | | @rijwind/sdk/client | REST client + types only | no (Node-safe) | | @rijwind/sdk/gl | createMap: the WebGPU engine with Map as fallback | yes (the fallback); the engine is in the package | | @rijwind/sdk/weather | weatherLayers: Vane weather layers for either map | no (needs @rijwind/vane) | | @rijwind/sdk/style.css | map stylesheet | — |

Errors

Every endpoint returns the same envelope on failure:

{
    error: 'quota_exhausted',                   // stable, machine-readable
    message: 'Monthly request quota exceeded.', // for humans
}

Common codes: missing_key, invalid_key, revoked_key, origin_blocked, quota_exhausted, matrix_too_large, isochrone_too_large. See the error reference.

Raw client

Need an endpoint that isn't wrapped? Drop down to the underlying openapi-fetch client — it speaks the full OpenAPI surface:

const { data } = await rijwind.raw.GET('/tiles/v1/token');

Versioning

@rijwind/sdk follows the API: 0.x.y while in preview, 1.x.y once the API has been stable for a quarter. Breaking changes ship in a major; additive endpoints and optional parameters in minors.

License

MIT, except dist/engine/: the WebGPU engine that @rijwind/sdk/gl loads is proprietary (all rights reserved; see dist/engine/LICENSE) and is shipped compiled only.