React Native Better Clustering
react-native-better-clustering is a drop-in replacement for
react-native-map-clustering:
same MapView + <Marker> API, with a C++ supercluster engine via
Nitro Modules instead of supercluster in JavaScript.
Migration
- import MapView from 'react-native-map-clustering'
+ import MapView from 'react-native-better-clustering'
See Migrating from react-native-map-clustering for the differences. Coming from another library? See Migrating from react-native-clusterer and Migrating from use-supercluster.
Why C++/Nitro?
react-native-map-clustering builds its supercluster index in JavaScript, on
the JS thread, so a large dataset holds up touches and renders while it loads.
MapView here builds the index in C++ on a background thread instead, without
changing how you write map screens. Reading the clusters for the visible region
is a synchronous native call from the JS thread, and markers still render
through react-native-maps.
Advanced APIs
Need full control over rendering? Use subpath exports:
/hooks:useClustererwhen you own theMapView/engine:Superclusterclass and geometry helpers/geojson: GeoJSON conversion utilities
Next steps
- Quick Start: install and render your first clustered map.
- Platform Setup: peers and prebuild.
- Migrating from react-native-map-clustering: what differs.
- Migrating from react-native-clusterer or use-supercluster: the hook's arguments, and what runs on which thread.
- MapView API: props, callbacks, and customization.
- Hooks API:
useClustererfor custom stacks.