GeoFire for JavaScript - Realtime location queries with Firebase
TypeScript JavaScript
Clone or download
MichaelSolati and jshcrowthe Migration to Typescript (#169)
* Migrate to Typescript

* Fix additional mocha tests

* Fix events for GeoQuery class

* Fix to kill mocha at end of test

* feat(firestore): early implementation of geofirestore

* test(firestore): implement test against realtime db to firestore

* test(geofirestore): check location against array instead of object

* test: fix tests for geofire callbacks and implement for geofirestore

* fix(firestore): fix single location removal by set function

* refactor: change vars to consts and use in instead of hasOwnProperty

* fix(firestore): set data from snapshot to variable to pass into decode

* refactor: renamed folders and small tweaks

* test: reintroduce coveralls support with tweaks

* test: increase mocha timeout

* test(firestore): modify "'key_exited' registrations can be cancelled" timing

* chore: remove firestore support

* build: migrate build process to rollup

* refactor(geofire): break out distance function

* refactor: introduce new interfaces and use maps instead of dicts

* fix: lock node version for tests and revert geoFireGetKey logic

* chore: update dependencies and support firebase 5.x.x

* refactor(GeoQuery): revert to using dict instead of a Map

* refactor(GeoQueryState): create interface for callbacks
Latest commit d5aecb8 Jun 29, 2018

GeoFire for JavaScript Build Status Coverage Status Version

GeoFire is an open-source library that allows you to store and query a set of keys based on their geographic location. At its heart, GeoFire simply stores locations with string keys. Its main benefit, however, is the possibility of retrieving only those keys within a given geographic area - all in realtime.

GeoFire uses the Firebase Realtime Database for data storage, allowing query results to be updated in realtime as they change. GeoFire selectively loads only the data near certain locations, keeping your applications light and responsive, even with extremely large datasets.

GeoFire is designed as a lightweight add-on to Firebase. To keep things simple, GeoFire stores data in its own format and its own location within your Firebase database. This allows your existing data format and Security Rules to remain unchanged while still providing you with an easy solution for geo queries.

A compatible GeoFire client is also available for Objective-C and Java.

Table of Contents

Downloading GeoFire

In order to use GeoFire in your project, you need to include the following files in your HTML:

<!-- Firebase -->
<script src=""></script>

<!-- GeoFire -->
<script src=""></script>

Use the URL above to download both the minified and non-minified versions of GeoFire from the Firebase CDN. You can also download them from the releases page of this GitHub repository.

You can also install GeoFire via npm or Bower. If downloading via npm, you will have to install Firebase separately (because it is a peer dependency to GeoFire):

$ npm install geofire firebase --save

On Bower, the Firebase dependency will be downloaded automatically:

$ bower install geofire --save



You can find a full list of our demos and view the code for each of them in the examples directory of this repository. The examples cover some of the common use cases for GeoFire and explain how to protect your data using the Firebase Database Security Rules.

Example Usage

Assume you are building an app to rate bars and you store all information for a bar, e.g. name, business hours and price range, at /bars/<bar-id>. Later, you want to add the possibility for users to search for bars in their vicinity. This is where GeoFire comes in. You can store the location for each bar using GeoFire, using the bar IDs as GeoFire keys. GeoFire then allows you to easily query which bar IDs (the keys) are nearby. To display any additional information about the bars, you can load the information for each bar returned by the query at /bars/<bar-id>.

Migration Guides

Using an older version of GeoFire and want to upgrade to the latest version? Check out our migration guides to find out how!


If you'd like to contribute to GeoFire, please first read through our contribution guidelines. Local setup instructions are available here.