add
Installs one or more registry components, resolving transitive dependencies and never overwriting local modifications.
npx mapcn-rn add <component...> [--overwrite] [--yes] [--renderer maplibre|mapbox]
npx mapcn-rn add --allWhat it does
- Reads
mapcn.json. If the project has none,addruns init first, then continues with the components you asked for. - Fetches the registry manifest and resolves every requested component's transitive
registryDependencies, topologically sorted -- already-satisfied dependencies are skipped, and the resolved set is printed before anything is written. - For each file:
- New file: written directly.
- Unmodified since install: upgraded silently if the registry version differs.
- Locally modified (or an untracked file already at that path): never overwritten. The new version is written to a
<name>.new.tsxsidecar instead, and the CLI prints adiffcommand to review it -- unless--overwriteis passed, in which case the original is snapshotted to.mapcn-backup/<timestamp>/first, then replaced.
- Installs any newly-required npm dependencies with the detected package manager.
- Writes the components' declared Expo config plugins and native permissions into
app.json— see Permissions. - Regenerates
components/ui/mapcn/index.ts, the barrel that re-exports everything installed. - Updates
mapcn.jsonwith the installed component versions and file hashes.
Where files land
Components are installed into components/ui/mapcn/, alongside a generated index.ts, so the whole library sits in one folder next to (not mixed into) your own components/ui files:
src/
components/ui/mapcn/
index.ts generated barrel -- rewritten on every add
map.tsx
map-marker.tsx
...
lib/mapcn/ shared utilities
hooks/
use-location-tracking.tsImport anything you have installed from a single path:
import { Map, MapMarker, MapClusterLayer, useLocationTracking } from "@/components/ui/mapcn";The barrel is generated, so edits to index.ts are overwritten on the next add. Everything else in the folder is yours to change. Renderer-internal adapters (map-renderer.tsx) are deliberately left out of the barrel, since their exports differ per renderer — import those directly when you need raw renderer access.
Install everything
npx mapcn-rn add --all--all installs every component available for the renderer recorded in mapcn.json. Combined with the auto-init above, this is the one-command path from an empty Expo project to every map primitive installed and doctor-clean:
npx mapcn-rn add --all --yesWith --yes and no existing config, setup is fully non-interactive and defaults to MapLibre with CARTO, which needs no API key. Pass --renderer / --provider to choose something else without prompts.
Flags
| Flag | Description |
|---|---|
--all | Install every component available for the active renderer. The <component...> argument becomes optional. |
--overwrite | Allow overwriting locally-modified files (always backed up first). |
--yes / -y | Skip the install confirmation prompt. |
--renderer <maplibre|mapbox> | Install the given renderer's variant instead of the one recorded in mapcn.json. Also used when add has to run init first. |
--provider <maptiler|carto|custom|mapbox> | Only used when add has to run init first. |
--registry <url> | Override the registry base URL. |
Example
npx mapcn-rn add cluster choropleth legend location-puckInstalling cluster automatically resolves and installs its map and core dependencies too, if not already present.