> ## Documentation Index
> Fetch the complete documentation index at: https://www.meilisearch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Firebase

> Sync your Firestore documents to Meilisearch using the official Firebase extension.

The official [firestore-meilisearch](https://github.com/meilisearch/firestore-meilisearch) extension automatically synchronizes documents from a Cloud Firestore collection to a Meilisearch index, enabling full-text search on your Firestore data.

<Note>
  [Meilisearch Cloud](https://www.meilisearch.com/cloud?utm_campaign=oss\&utm_source=docs\&utm_medium=firebase) is the easiest way to get a Meilisearch instance for use with Firebase.
</Note>

## Prerequisites

* A Firebase project on the Blaze (pay-as-you-go) plan
* Cloud Firestore set up in your Firebase project
* A running Meilisearch instance ([Cloud](https://cloud.meilisearch.com) or [self-hosted](/resources/self_hosting/getting_started/quick_start))
* A Meilisearch API key with write permissions

## Install the extension

You can install the extension using the Firebase Console or the Firebase CLI.

<Tabs>
  <Tab title="Firebase Console">
    Visit the [Firebase Extensions Hub](https://extensions.dev/extensions/meilisearch/firestore-meilisearch) and click **Install**.

    Follow the prompts to select your Firebase project and configure the extension.
  </Tab>

  <Tab title="Firebase CLI">
    ```bash theme={null}
    firebase ext:install meilisearch/firestore-meilisearch --project=YOUR_PROJECT_ID
    ```

    Replace `YOUR_PROJECT_ID` with your Firebase project ID.
  </Tab>
</Tabs>

## Configuration

During installation, you'll configure the following parameters:

| Parameter                    | Description                                                             |
| ---------------------------- | ----------------------------------------------------------------------- |
| **Cloud Functions location** | Region where the extension's functions will be deployed                 |
| **Collection path**          | The Firestore collection to sync (e.g., `products`, `articles`)         |
| **Fields to index**          | Comma-separated list of field names, or leave blank to index all fields |
| **Meilisearch index name**   | The name of the Meilisearch index to sync data to                       |
| **Meilisearch host**         | Your Meilisearch instance URL (must start with `http://` or `https://`) |
| **Meilisearch API key**      | An API key with permission to manage indexes                            |

## How it works

Once installed, the extension deploys a Cloud Function called `indexingWorker` that:

1. **Listens** for document creates, updates, and deletions in your specified collection
2. **Syncs** changes to your Meilisearch index in real-time
3. **Maps** Firestore document IDs to a `_firestore_id` field in Meilisearch

<Warning>
  The extension only monitors the specified collection, not subcollections. Install additional instances to sync other collections.
</Warning>

## Data format

### Document IDs

Firestore document IDs are automatically mapped to a `_firestore_id` field in Meilisearch. Any field named `_firestore_id` in your source documents will be ignored.

### Geolocation

For geo search functionality, name your GeoPoint field `_geo` in Firestore. Meilisearch will automatically recognize it for [geo search queries](/capabilities/geo_search/getting_started).

```javascript theme={null}
// Firestore document with geo data
{
  name: "Eiffel Tower",
  _geo: new firebase.firestore.GeoPoint(48.8584, 2.2945)
}
```

## Import existing documents

The extension only syncs documents created or modified after installation. To import existing documents, use the provided import script:

```bash theme={null}
npx @meilisearch/firestore-meilisearch-scripts import
```

<Tip>
  See the [import script documentation](https://github.com/meilisearch/firestore-meilisearch/blob/main/guides/IMPORT_EXISTING_DOCUMENTS.md) for detailed instructions.
</Tip>

## Search your data

Once your data is synced, you can search it using any Meilisearch SDK or the REST API:

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    import { Meilisearch } from 'meilisearch'

    const client = new Meilisearch({
      host: process.env.MEILISEARCH_URL,
      apiKey: process.env.MEILISEARCH_KEY
    })

    const results = await client.index('products').search('phone')
    console.log(results.hits)
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl "${MEILISEARCH_URL}/indexes/products/search" \
      -H "Authorization: Bearer ${MEILISEARCH_KEY}" \
      -H "Content-Type: application/json" \
      -d '{"q": "phone"}'
    ```
  </Tab>
</Tabs>

## Resources

* [GitHub repository](https://github.com/meilisearch/firestore-meilisearch)
* [Firebase Extensions Hub](https://extensions.dev/extensions/meilisearch/firestore-meilisearch)
* [Meilisearch blog: Firebase + Meilisearch](https://www.meilisearch.com/blog/firebase-meilisearch)
