Getting Started
react-native-nitro-h3 binds Uber’s H3 C library into a React Native app through Nitro Modules, so an H3 call runs in native code and answers a bigint.
1. Install the Package
Section titled “1. Install the Package”Add the package together with Nitro Modules:
bun add react-native-nitro-h3 react-native-nitro-modulesnpm install react-native-nitro-h3 react-native-nitro-modulesnpx expo install react-native-nitro-h3 react-native-nitro-modules installs the same versions in an Expo project, because Expo pins no version of its own for either package and hands both to the project’s package manager.
2. Set Up the Native Projects
Section titled “2. Set Up the Native Projects”Install the iOS pods, which links the native module into the iOS project:
cd ios && pod installExpo Go cannot load a native module, so generate the native projects for a development build:
npx expo prebuild3. Rebuild the App
Section titled “3. Rebuild the App”Rebuild the app so the native module is linked, with npx react-native run-ios or npx react-native run-android.
Build and start the development build with npx expo run:ios or npx expo run:android.
First Call
Section titled “First Call”One coordinate and one resolution give one cell, and that cell’s ring of neighbours comes back as a typed array:
import { latLngToCell, gridDisk, cellToString,} from 'react-native-nitro-h3'
// the H3 cell for San Francisco at resolution 9const cell = latLngToCell(37.7749, -122.4194, 9) // 617700169957507071n
// the cell and its six neighboursconst neighbours = gridDisk(cell, 1) // BigUint64Array(7)
const hex = cellToString(cell) // "89283082803ffff"latLngToCell returns a bigint, and gridDisk returns a BigUint64Array.
Both are explained in Cell Indexes and bigint.
From here, Migrating from h3-js covers a move off h3-js, Typed Arrays and Batch Calls covers workloads over many cells, and the API Reference documents every exported function.