Skip to content

Getting started

Audience: package users installing react-native-nitro-h3 for the first time. This page takes you from an empty project to a first cell: install, one call, and the requirements the build has to meet.

  1. Add the package together with Nitro Modules.

    Terminal window
    bun add react-native-nitro-h3 react-native-nitro-modules
  2. Install the iOS pods.

    Terminal window
    cd ios && pod install
  3. Rebuild the app so the native module is linked, with npx react-native run-ios or npx react-native run-android.

import {
latLngToCell,
gridDisk,
cellToString,
} from 'react-native-nitro-h3'
// H3 cell for San Francisco at resolution 9
const cell = latLngToCell(37.7749, -122.4194, 9)
// Get neighboring cells
const neighbours = gridDisk(cell, 1)
console.log(neighbours.length) // 7
console.log(cellToString(cell)) // "89283082803ffff"

latLngToCell returns a bigint, and gridDisk returns a BigUint64Array. Both are explained in Cell indexes and bigint.

Platform Requirement
React Native 0.76+
Nitro Modules 0.37.0 or newer
C++ C++20-compatible toolchain
iOS React Native deployment target
Xcode recent stable release
Android minSdk 24
Android SDK compileSdk 36
Android NDK 27.1.12297006
H3 C library 4.5.0, vendored

The package requires the New Architecture, the default since React Native 0.76. The iOS and Android build workflows compile the example app against React Native 0.87.0.