Skip to content

Repository files navigation

react-native-nitro-h3

react-native-nitro-h3

Fast native H3 geospatial indexing for React Native.

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

react-native-nitro-h3 brings Uber's H3, the hexagonal hierarchical geospatial index, to React Native on iOS and Android. It vendors the H3 C sources and calls them directly from C++ instead of running them through JavaScript.

  • ⚡ Up to ~800× faster than h3-js
  • 🧬 H3 as compiled C++, called through Nitro Modules
  • 🔢 bigint cell indexes instead of 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.



🚀 Installation

Install from npm together with Nitro Modules and see Getting Started.

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

👇 Usage

One coordinate and one resolution give one cell, and one cell gives its neighbours as a typed array over the native buffer:

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) // 617700169957507071n
const id = cellToString(cell) // '89283082803ffff'

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

Coming from h3-js, read the migration guide.


Links


📄 License

react-native-nitro-h3 is released under the MIT licence, and the vendored H3 C sources under third_party/h3 keep their Apache-2.0 LICENSE and NOTICE files.

About

Native H3 geospatial indexing for React Native, about 800× 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