Skip to content

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.

Add the package together with Nitro Modules:

Terminal window
bun add react-native-nitro-h3 react-native-nitro-modules

npx 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.

Install the iOS pods, which links the native module into the iOS project:

Terminal window
cd ios && pod install

Rebuild the app so the native module is linked, with npx react-native run-ios or npx react-native run-android.

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 9
const cell = latLngToCell(37.7749, -122.4194, 9) // 617700169957507071n
// the cell and its six neighbours
const 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.