Skip to content

Repository files navigation

react-native-nitro-h3

react-native-nitro-h3

Fast H3 geospatial indexing for React Native, powered by Nitro Modules.

npm version CI License: MIT Platforms: iOS and Android Vendored H3 v4.5.0

The showcase app: a hexagon grid follows the map, a cell splits into its children, a million points fold into cells

Brings Uber's H3, the hexagonal hierarchical geospatial index, to native iOS and Android applications. It vendors the H3 C library and calls it directly from native code instead of running it through JavaScript.

The result is a native H3 binding designed for performance-sensitive React Native workloads.

  • ⚡ Up to 862× faster than h3-js. See the benchmark →
  • 🧬 H3 as compiled C++, called through Nitro Modules
  • 🔢 bigint cell indexes, no hexadecimal strings
  • 📦 Typed-array results over the native buffer
  • 🧵 Batch calls for whole coordinate and cell arrays
  • ⏱️ Async variants on a background thread
  • 🔁 The h3-js names and a migration guide

📚 Read the documentation for the guides, the API reference and the migration from h3-js.



🚀 Installation

Install from npm together with Nitro Modules:

bun add react-native-nitro-h3 react-native-nitro-modules
cd ios && pod install

Getting started has the npm and Expo commands, the New Architecture note and the requirements.


👇 Usage

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)
console.log(cell) // 617700169957507071n
console.log(cellToString(cell)) // "89283082803ffff"

// The cell and its six neighbours, as one BigUint64Array
const neighbours = gridDisk(cell, 1)
console.log(neighbours.length) // 7

Coming from h3-js? Read the migration guide: the h3-js names with unit suffixes instead of a unit argument, cells as bigint, cell sets as BigUint64Array.


Links


📄 License

react-native-nitro-h3 is released under the MIT License. The vendored H3 C sources keep their Apache-2.0 LICENSE and NOTICE files.

About

Native H3 geospatial indexing for React Native, up to 862x faster than h3-js. Uber's H3 C library exposed through Nitro Modules, with bigint cell indexes, typed-array results and batch operations.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages