Library / SDK
firebase/geofire-js avatar
firebase/geofire-js

GeoFire for JavaScript: Realtime Geographic Queries on Firebase

GeoFire for JavaScript - Realtime location queries with Firebase

1,446 stars338 forksTypeScriptMIT

At a glance

What is it?
GeoFire for JavaScript adds realtime geographic queries to Firebase Realtime Database while keeping location data separate from application records. It fits nearby-key lookups, but it does not support Cloud Firestore and requires a compatible Firebase setup.
Who is it for?
Adopt GeoFire when the application uses Firebase Realtime Database and needs realtime searches for string keys near a coordinate, while keeping location indexes separate from existing records. Do not choose it for a Cloud Firestore application or when a full geospatial database already provides the required querying model.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 3 days ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 7, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • firebase/geofire-js1,446 ★ · +1
Star history
Repository2026-10-162026-11-07
firebase/geofire-js1.4k1.4k

1 Stars in the last 22 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

GeoFire's Firebase Realtime Database boundary

GeoFire solves a specific data-access problem: retrieving a set of string keys whose associated locations fall within a geographic area. The target audience is application developers who already use Firebase Realtime Database and want nearby searches without loading every application record. The bar-rating example in the README uses bar IDs as the GeoFire keys, while the rest of each bar record remains at `/bars/<bar-id>`. A nearby query can therefore return bar IDs, after which the application loads the corresponding bar details from its existing data.

This separation is central to the design. GeoFire stores location information in its own format and its own Realtime Database location. The README says this allows an existing data format and existing Security Rules to remain unchanged. That does not mean no database configuration is required. The GeoFire location must still be protected appropriately, and the repository includes an `examples/securityRules/` directory for this purpose. The documentation links to Firebase Database Security Rules rather than claiming that the query works safely without rules.

GeoFire also has a clear platform boundary. It is designed for Firebase Realtime Database, not Cloud Firestore. For Firestore, the README directs developers to Firebase documentation about implementing geoqueries on Firestore. This distinction matters because adopting GeoFire does not turn a Firestore collection into a geospatial query layer.

Separate geospatial index data flow

At its core, GeoFire stores locations against string keys. The application chooses the identity of each key, such as a bar ID, and GeoFire maintains those key-location relationships in a separate Realtime Database area. A geographic query returns keys within the requested area, not the complete domain records associated with those keys. The application remains responsible for joining those keys to data stored elsewhere.

The README says query results update in realtime as they change. It also says GeoFire selectively loads data near specified locations instead of loading the entire dataset. Based on that architecture, a realtime listener operates over the geospatial index, while application records can follow their existing Firebase structure. This is useful for mobile or browser interfaces where transferring unrelated records would add unnecessary work.

The separate-index design also creates a consistency responsibility. The application must keep its GeoFire key-location entries aligned with the records it wants to search. The README's example does not specify a transaction, cleanup procedure, or stale-key policy, so those details are not established there. A removed or moved record could leave an index entry unless the application removes or updates it. The `examples/` directory contains demos, but the README does not document a universal synchronization pattern.

Installing GeoFire and Firebase in a JavaScript project

GeoFire lists the Firebase JS SDK as a peer dependency. Its documented installation command installs both packages and saves them in the project configuration:

bash
$ npm install geofire firebase --save

After this command, the project should have declarations for `geofire` and `firebase` in its npm dependencies. The README also provides a Bower route:

bash
$ bower install geofire --save

That command is documented for users of Bower, with the Firebase dependency downloaded automatically. The repository root contains a private Lerna package named `geofire-wrapper`, but the root `package.json` describes monorepo scripts rather than a separate end-user package. The end-user installation documented in the README is therefore the npm or Bower command above.

For an HTML-only deployment, the README directs users to the GitHub releases page for a minified or non-minified GeoFire file. Its example also loads Firebase scripts from `https://www.gstatic.com/firebasejs/8.0.1/`. The GeoFire URL is explicitly marked as a project-specific substitute:

html
<script src="https://my-firebase-project.web.app/geofire-5.0.1.min.js"></script>

That snippet is a deployment template, not a universal hosted path. The README does not document browser support, module-format configuration, or a complete initialization example for the current package layout.

Starting with keyed nearby searches

A first real use begins with a key that represents an existing record. In the README's bar example, `/bars/<bar-id>` contains the bar information and GeoFire uses the same bar ID as its geospatial key. The application must have access to a Firebase Realtime Database instance and must choose the database location where GeoFire will store its index. The README does not name that path or show the current constructor signature, so a complete code example would require `docs/reference.md`.

The conceptual sequence is narrow. Store the bar's location with its bar ID in GeoFire. Request nearby keys from a latitude and longitude, with the desired radius encoded through the documented API. Attach a listener if the interface must reflect subsequent changes. Receive bar IDs, then read the corresponding records from `/bars/<bar-id>`. The repository includes `examples/queryBuilder/`, but its contents are not documented in the README.

This is not a replacement for application search fields. GeoFire answers which keys are geographically nearby. It does not, according to the README, provide text search, price filtering, opening-hour filtering, ranking rules, or a Firestore-style compound query model. Those requirements may still be handled by Firebase data, but the README does not document how to combine them with GeoFire results.

Realtime Database deployment constraints

GeoFire is useful only when the surrounding application already fits Firebase Realtime Database conventions. Its data model is hierarchical, application records remain under paths such as `/bars/<bar-id>`, and the geospatial index occupies a separate location. Moving an application from Firestore to Realtime Database merely to use GeoFire would introduce a different persistence model, security configuration, and client integration.

The README highlights selective loading, but it does not publish a benchmark or define a guaranteed query limit. It also does not document how GeoFire behaves when a listener becomes too broad, when many keys occupy the same area, or when Firebase usage and pricing thresholds are reached. Those operational questions need answers from the API documentation and the Firebase Realtime Database documentation rather than inference from the README.

The HTML example uses Firebase 8.0.1 script URLs and a GeoFire 5.0.1 file name. Those are concrete strings in the README, but they are examples rather than a declared compatibility matrix. A browser deployment should verify the released GeoFire file against the Firebase SDK version used by the application. The npm instruction is clearer for a package-managed project because it asks the package manager to install both declared libraries.

GeoFire and Firestore geoqueries compared

The closest alternative named by the project is Firebase's documented approach to implementing geoqueries on Firestore. The difference is the persistence and integration layer, not the use case. GeoFire adds keyed location storage and realtime geographic queries to Firebase Realtime Database. The README directs Firestore developers to Firebase's geoquery documentation. The README does not claim that either approach can be moved to the other without changes.

A developer choosing between them should first identify the database already used by the application. If the records live in Realtime Database and only bar IDs, user IDs, or similar strings need to be found nearby, GeoFire provides a documented add-on. If the records live in Firestore, the README sends the developer to the Firestore geoquery documentation rather than suggesting a cross-database adapter.

Another possible alternative is a dedicated geospatial database, but the repository does not name or document one. This article therefore does not add a competitor comparison that would require unverified claims about query primitives, scaling, deployment, or licensing. The defensible comparison here is GeoFire for Realtime Database versus Firebase's Firestore geoquery approach.

Maintenance, releases, and upgrade work

The repository is not archived, and its last push was on 2026-05-28. The available release list shows `6.0.0` dated 2022-07-13, `v5.2.0` dated 2021-02-24, and `v5.1.0` dated 2020-11-09. The repository therefore has a recent recorded code push, but the release history does not show a recent package release. Whether maintenance changes have produced a new published package cannot be established from the release list alone.

The README points users to `docs/migration.md` when upgrading from an older GeoFire version. That is the project-specific upgrade reference to consult, especially because the documented HTML example names `geofire-5.0.1.min.js`, while the release list includes `6.0.0`. The article cannot state the migration steps because the migration guide is not included in the README.

The package metadata identifies the repository as MIT licensed, and the README says GeoFire is licensed under the MIT License. This is a licensing fact, not legal advice. The cost of an upgrade includes checking the migration guide, Firebase SDK compatibility, Security Rules, and the separate geospatial index. The README does not document a compatibility matrix or a formal support policy.

Editorial conclusion

Adopt GeoFire when the application uses Firebase Realtime Database and needs realtime searches for string keys near a coordinate, while keeping location indexes separate from existing records. Do not choose it for a Cloud Firestore application or when a full geospatial database already provides the required querying model. Before adoption, verify the API version documented in `docs/reference.md`, the intended Realtime Database path, the required Security Rules, and the behavior of your chosen query builder.

Frequently asked questions

How do I install GeoFire for JavaScript?

Install GeoFire together with its Firebase JS SDK peer dependency by running `npm install geofire firebase --save`. The README also documents `bower install geofire --save` for Bower projects.

Does GeoFire for JavaScript support Cloud Firestore?

No. GeoFire is designed as an add-on to Firebase Realtime Database. The README directs Firestore users to Firebase documentation about implementing geoqueries on Firestore.

Where does GeoFire store location data?

GeoFire stores location data in its own format and its own location within Firebase Realtime Database. This keeps application records and their existing data format separate from the geospatial index.

Can I use GeoFire in a browser without npm?

The README says to download a minified or non-minified GeoFire file from the repository releases page and deploy it, for example with Firebase Hosting. The README's HTML example also loads Firebase scripts and uses a project-specific GeoFire URL.

What does a GeoFire query return?

A query returns string keys within the requested geographic area. In the README's bar example, those keys are bar IDs, and the application can then load each bar's information from `/bars/<bar-id>`.

How do I upgrade an older GeoFire version?

The README directs existing users to `docs/migration.md`. The README does not include that guide's individual migration steps, so it does not confirm a specific upgrade procedure.

Official sources

  1. firebase/geofire-js on GitHub
  2. Issues
  3. License: MIT
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/firebase-geofire-js.svg)](https://hysenlabs.com/projects/firebase-geofire-js)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/firebase-geofire-js.svg)](https://hysenlabs.com/projects/firebase-geofire-js)

Was this useful?