finds.dev← search

// the find

mourner/flatbush

★ 1,591 · JavaScript · ISC · updated Jul 2026

A very fast static spatial index for 2D points and rectangles in JavaScript 🌱

Flatbush is a packed Hilbert R-tree implementation for spatial indexing of 2D rectangles and points. It's static — you build it once, then query; no incremental inserts. The target is anyone doing spatial queries on large datasets in JS: map renderers, collision detection, computational geometry.

The serialization story is genuinely good — the entire index lives in a single ArrayBuffer, so you can transfer it between workers with zero-copy, persist it to disk, or reconstruct it with Flatbush.from(). The performance numbers are credible: 1M rectangles indexed in 109ms on M1 is fast for JS. The ArrayType parameter letting you swap Float64Array for Int32Array is a practical optimization most spatial libs skip. KNN search (neighbors()) is included, which saves you from implementing it yourself on top of a bare bounding-box index.

Static-only is a real constraint that will bite anyone who tries to use this for live data — if you need to add or remove items at runtime, you're rebuilding the whole index. The library is a single 300-line file with no TypeScript source (tsconfig.json is just for editor support), so if you want to understand or modify the algorithm you're reading dense typed array arithmetic. No geographic/spherical distance support in the base library — you need the separate geoflatbush extension, which isn't mentioned until halfway through the README. Also no support for arbitrary dimensions; if your data is 3D, look elsewhere.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →