Skip to content

Accessible map interfaces for React and MapLibre

MapCairn is an open-source React SDK for public-interest maps: the interface around a MapLibre map, with search, measuring, drawing and a layers panel, for the search and routing services you choose.

A cairn is a pile of stones that walkers add to, marking the way for whoever comes next.

Try the playground
Package manager
npm install @mapcairn/sdk react react-dom maplibre-gl
pnpm add @mapcairn/sdk react react-dom maplibre-gl
yarn add @mapcairn/sdk react react-dom maplibre-gl
bun add @mapcairn/sdk react react-dom maplibre-gl

It adds the SDK and its three peers. Needs React 19, maplibre-gl 6.18 or later and a bundler that handles CSS imports (tried with Vite).

View on GitHub

The latest release is 0.2.0, released on 23 November 2026. How ready it is

Screenshot: The MapCairn playground over Cape Town with the Measure tool open: a line of 3.37 km measured from Newlands to Sybrand Park, with its length and the Distance and Area choices in the toolbar.Screenshot: The MapCairn playground over Cape Town with the Measure tool open: a line of 3.37 km measured from Newlands to Sybrand Park, with its length and the Distance and Area choices in the toolbar.
Screenshot: The MapCairn playground over Cape Town on a wide screen with the Measure tool open: a line of 3.37 km measured from Newlands to Sybrand Park, with its length and the Distance and Area choices in the toolbar.Screenshot: The MapCairn playground over Cape Town on a wide screen with the Measure tool open: a line of 3.37 km measured from Newlands to Sybrand Park, with its length and the Distance and Area choices in the toolbar.
Screenshot of the playground, measuring across Cape Town. The Try the playground button above opens the real thing.Map credits: © OpenStreetMap contributors, OpenFreeMap, OpenMapTiles, MapLibre.

What you get

  • Accessible by default

    WCAG 2.2 AA is the target in the light and the dark theme. Every gesture has a keyboard or single-tap equivalent, the map pans and zooms from the keyboard, screen readers are told what changes, and automated accessibility checks run on every pull request.

  • Private by design

    It asks for nothing until a person does: the basemap's tiles when the map shows, a layer when it is turned on, a search when it is submitted. The one exception is search suggestions, which a host may turn on and which send the text typed so far. No accounts and no tracking.

  • The whole interface, not just the map

    Search, measuring, drawing and editing shapes, directions through a routing service you choose, a layers panel, saving the map as an image and links that share what is on the map, in a light and a dark theme.

  • Your own providers, without forking

    Use your own search, routing and tiles without forking the interface: each service it talks to can be replaced. In-memory stand-ins for every service let you test the interface without WebGL or a network.

When it fits, and when it does not

It fits a team that

  • builds in React and wants a ready-made, accessible map interface;
  • shows open data that the browser fetches straight from its provider, only when asked;
  • wants to test its map interface without WebGL;
  • needs the interface in its own language and can supply the words, which come from a message catalogue the host provides;
  • needs right-to-left languages: the layout mirrors, and plurals, lists, numbers and units follow the language.

It does not fit if you need

  • a hosted service, a dataset or a GIS analysis engine;
  • a map engine other than MapLibre GL JS;
  • a prebuilt bundle for pages without React;
  • a bundler other than Vite that has been tried with it: only Vite has;
  • translations or fonts in the box: the SDK ships British English, and the host supplies the words for any other language and a font for a script that IBM Plex Sans does not cover;
  • more than one maintainer behind it: the project has one volunteer maintainer;
  • to keep an app's source to yourself while you distribute it: the AGPL-3.0 asks you to offer the source of an app you distribute with the SDK inside.

Licence and cost

What the AGPL-3.0 asks of your app

MapCairn is AGPL-3.0-only, an open-source licence that allows commercial use: you may use it, change it, sell a product built on it and charge for services that run it.

The condition is that the source stays available. An app you distribute with the SDK inside, including by serving it to people's browsers, is offered under the AGPL-3.0 with the corresponding source of the code you combine with the SDK and serve with it.

An app that only your own staff use is not distributed, so that does not apply to it. If you modify the SDK and let people use your version over a network, you must offer them its source.

The licence guide says it in plain words, with examples. It is not legal advice.

What it costs

The SDK costs nothing to install or use.

The services a map uses, such as tiles, search and routing, are yours to choose, and each provider has its own terms.

The SDK's production dependencies are all permissively licensed, and the project's checks fail if one is not.

How ready it is

It is before version 1.0 and not stable: a minor release can change the public API, and each release's notes say what to change.

Where it runs

The reference site runs on it in production, and every change passes the project's unit, browser and accessibility tests before it is merged.

What has been tried

The published packages are checked in a plain Vite and React app in Chromium. The reference site's browser tests run in Chromium and WebKit. Other frameworks and bundlers have not been tried.

What it lacks

There is no prebuilt bundle for pages without React, and the project has one volunteer maintainer. The capability matrix lists what the SDK has, partly has and lacks.

Embed a map

The install command adds @mapcairn/sdk and its peers. A whole Vite and React app is three files: index.html, a short style sheet that gives the map a height, and src/main.tsx. This part of src/main.tsx mounts the map: MapView with a starting view, a basemap and the SDK's interface round it.

src/main.tsx, an excerpt
function MapScreen() {
  const basemaps = useBasemaps();
  const { resolved } = useTheme();
  return (
    <MapView
      initialView={{
        center: { lat: -33.92, lng: 18.42 },
        zoom: 11,
        bearing: 0,
      }}
      basemap={defaultBasemapFor(basemaps, resolved)}
      chrome={(background) => <Chrome background={background} />}
    />
  );
}

Search and the rest of the interface run on in-memory stand-ins until you add adapters, and the map asks a public tile provider for its tiles once it mounts, so choose the basemap whose terms and privacy you accept.

The embedding walkthrough has all three files, what each part does and the Content Security Policy the page needs. examples/embed is a fuller app that uses the SDK only through its public entry points.

Questions

Which packages does it install?

One, @mapcairn/sdk, which re-exports the packages below; the MapLibre adapter is at the subpath @mapcairn/sdk/adapter-maplibre. Each is also published on its own, as the advanced option for a host that wants fewer dependencies.

@mapcairn/core: the port interfaces, pure logic, basemap definitions, fakes and contract suites. No React and no browser globals.

@mapcairn/map: the map interface, from the chrome, the sheet and its panels to the tools and MapView.

@mapcairn/react: generic React hooks.

@mapcairn/theme: the typed design tokens and their contrast calculations.

@mapcairn/adapter-maplibre: the MapLibre GL JS map adapter. It is the only part that imports a map engine, and the umbrella's root never does.

Which frameworks does it work with?

React 19, with a bundler that handles CSS imports: the styles are compiled stylesheets, so no style plugin is needed. Only Vite has been tried. The map engine is MapLibre GL JS, reached through an adapter.

What does the playground use?

The playground is the reference site, built from these packages. Its search, directions and data layers are this site's adapters and definitions, built on public community services (Nominatim for search and the FOSSGIS Valhalla server for directions) that are not meant for other sites' production traffic.

It counts page views with Cloudflare Web Analytics, which is cookieless, and its browser contacts the map tile providers, the search and routing services when you use them, and a layer's provider when you turn it on, as its privacy policy lists.

Your app supplies its own providers. The SDK ships the interface, the MapLibre adapter and in-memory fakes.