---
name: react-native-better-clustering
description: >-
  Expert guide to react-native-better-clustering — a drop-in clustered MapView for react-native-maps backed by a C++ supercluster engine over Nitro/JSI. Use when installing, configuring, or debugging it; when clustering is slow, wrong, or flickering; when handling thousands of map markers; when migrating from react-native-map-clustering or react-native-clusterer; and when changing the library's TypeScript, C++, or Nitro specs. Also use before writing any performance claim about map clustering, pan, zoom, or marker frame rate.
license: MIT
metadata:
  package: react-native-better-clustering
  version: "1.0.0"
  commit: 7c7d659046a3d1bb8b7d4cb06a94f6e0d509862e
  verified: "2026-08-21"
  repository: https://github.com/gmi-software/react-native-better-clustering
  audience: library users and library contributors
  tags: react-native, clustering, maps, markers, geospatial, supercluster, nitro, jsi, cpp, performance, ios, android, expo
title: react-native-better-clustering
canonical_url: https://skilld.dev/gh/gmi-software/better-skills/react-native-better-clustering
last_updated: 2026-09-27T09:50:45.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/aggregation.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/aggregation.md), [references/algo.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/algo.md), [references/api.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/api.md), [references/architecture.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/architecture.md), [references/contributing.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/contributing.md), [references/debugging.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/debugging.md), [references/migration.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/migration.md), [references/performance.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/performance.md), [references/rendering.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/rendering.md), [references/setup.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/setup.md).
>
> If the user asked to install this Skill, run `npx skilld install gmi-software/better-skills/react-native-better-clustering`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/react-native-better-clustering`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/gmi-software/better-skills/react-native-better-clustering) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/react-native-better-clustering`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/react-native-better-clustering --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/react-native-better-clustering --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# react-native-better-clustering

Drop-in clustered `MapView` for `react-native-maps`. Clusters are computed in C++ via a Nitro
HybridObject; every visible bubble/leaf is still a React `react-native-maps` `<Marker>`.

**Source is truth.** Where the library README and the code disagree, follow the code.

Paths like `package/src/...` are relative to a **library checkout**, not this skills repo.

## Version verification

```text
Package:            react-native-better-clustering
Version:            1.0.0
Commit:             7c7d659046a3d1bb8b7d4cb06a94f6e0d509862e
Verification date:  2026-08-21
```

```bash
npm view react-native-better-clustering version
node -p "require('react-native-better-clustering/package.json').version"
```

If your version differs, re-read `node_modules/react-native-better-clustering/src/` before trusting
internals.

## When to use

- Installing / configuring clustering on a React Native map
- Migrating from `react-native-map-clustering` or `react-native-clusterer`
- Thousands of markers, pan/zoom jank, flicker, wrong membership
- Native crash or Nitro load failure involving this package
- Aggregating cluster values (`clusterProperties`)
- Changing the C++ engine, Nitro spec, or React layer
- Reviewing any performance claim about clustering / marker FPS

## When NOT to use

| Situation | Instead |
| --- | --- |
| Base map / tiles / camera / gestures | Load the `react-native-maps` skill |
| `react-native-better-maps` | Load that skill — different library, native clustering |
| Mapbox / MapLibre / `@rnmapbox/maps` | Those SDKs cluster internally |
| Non-geographic clustering | This engine is lon/lat Web Mercator only |

## Core architecture

1. **Compute is C++; drawing is React.** `ClusterEngineCore` builds the hierarchy; the default
   `MapView` mounts one RN Maps `<Marker>` per visible node.
2. **One HybridObject, not a map view.** Nitro autolinks `ClusterEngine` → `HybridClusterEngine`.
3. **Load copies; query converts.** `packPoints` → `setPoints` memcpy → sync `getClusters` that
   allocates one JS object per node.
4. **Rebuilds are all-or-nothing.** No incremental insert API; `data` identity change destroys
   and rebuilds.
5. **Region sync is throttled** (`clusterUpdateIntervalMs` default `100`).

Details: [architecture.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/architecture.md).

### Thread safety (CRITICAL)

```text
ClusterEngineCore is NOT thread-safe.
No mutex / lock / atomic protects build state.

Do not issue concurrent buildAsync / getClusters / getChildren / getLeaves / isBuilt
against the same engine instance.

Supercluster lifecycle gating is incidental protection only.
createClusterEngine() (headless) provides no such guarantee.
```

`buildAsync` moves work off the JS thread — that is **not** concurrent-query safety.
For continuous querying during a rebuild, build a second engine fully, then swap.
→ [architecture.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/architecture.md)

## API guidance

| Import | Surface |
| --- | --- |
| `react-native-better-clustering` | Drop-in clustered `MapView` |
| `.../hooks` | `useClusterer` — you own the `MapView` |
| `.../engine` | `Supercluster`, `createClusterEngine` — headless |
| `.../geojson` | Feature helpers |
| `.../utils` | `packPoints`, etc. |
| `.../clusterer` | `Clusterer` component |

**`clusterProperties` is NOT a root `MapView` prop.** Aggregation exists only on `/engine` and
`/hooks` (`sum` \| `min` \| `max` only). Surface: [api.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/api.md). Deep detail:
[aggregation.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/aggregation.md).

## Problem → reference routing

| Problem | Start here |
| --- | --- |
| Concurrent engine / headless threading | [architecture.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/architecture.md) |
| **Installation & setup** | [setup.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/setup.md) |
| Blank Android map | [setup.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/setup.md) |
| Basic usage / which API | [api.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/api.md) |
| Slow / "make it 2× faster" | [Canonical optimization](#canonical-optimization-workflow) → [performance.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/performance.md) |
| 10k+ markers / ~20 FPS pan | [performance.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/performance.md) |
| Marker re-renders / flicker | [rendering.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/rendering.md) |
| Wrong membership / viewport edge | [algo.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/algo.md) |
| **Aggregation (`clusterProperties`)** | [aggregation.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/aggregation.md) + [api.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/api.md) |
| **Migration** | [migration.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/migration.md) |
| **Regression / PR slower** | [performance.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/performance.md) |
| Debugging unknown | [debugging.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/debugging.md) |
| Platform iOS / Android | [setup.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/setup.md), [debugging.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/debugging.md) |
| Testing / contributing | [contributing.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/contributing.md) |

## Canonical optimization workflow

```text
1. Establish baseline
2. Define workload
3. Profile
4. Identify bottleneck
5. Form hypothesis
6. Smallest change
7. Benchmark
8. Compare before vs after
9. Add regression coverage
```

Vague "2× faster" → reframe first: point count, distribution, pan/zoom/load, platform, device,
debug vs release, metric, current baseline. Profiling: [performance.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/performance.md).

**Do not** rewrite the KD-tree without a profile, add memoization that does not stabilize
identity, or claim FPS without measuring release builds on a real device.

## Common mistakes

- Treating clustering FPS as engine FPS — visible RN Maps markers are usually the ceiling
- Concurrent `buildAsync` + query on one headless engine
- Passing `clusterProperties` to root `MapView`
- Claiming "zero-copy" / "60 FPS at 10k" — not supported by source
- Optimising without a baseline workload
- Assuming Jest covers C++ clustering (it mocks Nitro)

## Troubleshooting

1. Name the layer: compute / JSI / React commit / RN Maps annotations → [performance.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/performance.md)
2. Name the trigger: dataset identity, region event, settle, mount
3. Measure on the failing platform → [performance.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/performance.md)
4. Then fix → [debugging.md](https://skilld.dev/api/skills-raw/gmi-software/better-skills/react-native-better-clustering/references/debugging.md)

Decision tree and real error strings live in the debugging reference.

## Known limitations

| Limitation | Consequence |
| --- | --- |
| Rendering is RN Maps markers | Visible count, not point count, sets FPS ceiling |
| `ClusterEngineCore` not thread-safe | Serialize build/query per instance |
| No incremental updates | `data` identity change rebuilds everything |
| `clusterProperties` not on root MapView | Use `/hooks` or `/engine` |
| New Architecture + no Expo Go | RN 0.78+; needs a development build |
| No CI performance gate | Regressions need your own measurement |

## Accuracy

Label claims **SOURCE FACT** / **TEST FACT** / **BENCHMARK FACT** / **EXAMPLE FACT** / **INFERENCE**.
Banned as fact: "zero-copy", "zero-bridge", "no JS overhead", "10k markers at 60 FPS".

2D KD-tree range/`within` complexity is typically **O(√n + k)** (not O(log n + k)). Build walks
`current` in **array/ingest order**; the tree answers neighbour queries only.
