CLI
init
Sets up a fresh project -- renderer, basemap provider, mapcn.json, Expo config, and the base map component.
npx mapcn-rn init [--renderer maplibre|mapbox] [--provider maptiler|carto|custom|mapbox] [--all] [--components a,b] [--yes]init is the entrypoint: it configures the project and installs the components you pick, in one pass.
What it does
- Detects the project (Expo vs. bare RN,
srclayout) and warns ifexpoisn't a dependency. - Prompts for a renderer, then a compatible basemap provider (skipped for Mapbox, which has no separate provider prompt), unless
--renderer/--providerare passed. - Detects the package manager (lockfile-based), styling system (Uniwind/NativeWind/none), and path aliases (
components.jsonif present, otherwise mapcn's defaults). - Asks which components to install (see below).
- Writes
mapcn.json(schema version 2). - Installs the renderer's npm package with the detected package manager.
- Adds the renderer's Expo config plugin to
app.json, if readable, and warns if both@maplibre/maplibre-react-nativeand@rnmapbox/mapsend up listed (they cannot coexist in one Expo app). - Scaffolds a placeholder for the provider's required public env key in
.env.example, if the provider needs one. - Installs the selected components and their transitive dependencies via the same logic as
add, including their native permissions and the generatedcomponents/ui/mapcn/index.tsbarrel.
Choosing components
After the renderer and provider, init offers three options:
| Option | Installs |
|---|---|
| Minimal | map, marker, popup, controls — enough for a map with pins you can tap |
| Everything | every component available for the renderer |
| Let me choose | a checkbox list grouped by category; selecting a category row toggles the whole group |
core is never listed: it is a transitive dependency of everything and is always installed.
To skip the picker, pass the choice up front:
npx mapcn-rn init --components map,cluster,legendFlags
| Flag | Description |
|---|---|
--renderer <maplibre|mapbox> | Skip the renderer prompt. |
--provider <maptiler|carto|custom|mapbox> | Skip the provider prompt. |
--all | Install every component available for the renderer, skipping the picker. |
--components <a,b,c> | Install exactly these components, skipping the picker. Takes precedence over --all. |
--yes / -y | Skip every prompt. Defaults to MapLibre with CARTO and the Minimal component set unless --renderer / --provider / --all / --components say otherwise. |
--registry <url> | Override the registry base URL (default https://mapcn-rn.dev/r). Point this at a local directory or file:// path for local development. |
If mapcn.json already exists, init asks for confirmation before re-running (skipped with --yes).
Example
Fully non-interactive, with every component:
npx mapcn-rn init --renderer maplibre --provider maptiler --all --yesRelated
add · doctor · Installation · Configuration