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

# Migrating from Firebase

> Step-by-step guide to moving your Firebase Realtime Database to Lark

Moving from Firebase Realtime Database to Lark is straightforward. Your code, security rules, and data model all carry over.

<Steps>
  <Step title="Create a Lark project">
    Create a project in the [Lark dashboard](https://dashboard.lark.sh). Note your project ID, as you'll need it for the connection URL.
  </Step>

  <Step title="Plan your database layout">
    If your Firebase app stores multiple independent data silos (game rooms, workspaces, etc.) under path prefixes, Lark can split them into separate databases automatically. See [Database routing](/firebase/database-routing) for your options.
  </Step>

  <Step title="Configure Firebase Auth (if applicable)">
    If you use Firebase Auth, enter your Firebase project ID in the **Firebase Auth Project ID** field. This lets Lark validate your users' tokens. See [Firebase Auth with Lark](/firebase/auth) for details.
  </Step>

  <Step title="Migrate security rules">
    Copy your Firebase RTDB security rules into Lark's security rules editor. The syntax is identical. Paste them in and click **Save Rules**.

    You can find your current rules in the Firebase console under Realtime Database > Rules.
  </Step>

  <Step title="Export your data">
    In the Firebase console, export your database as JSON. Or use the Firebase CLI:

    ```bash theme={null}
    firebase database:get / > backup.json
    ```

    For large databases, consider exporting individual paths to keep file sizes manageable.
  </Step>

  <Step title="Import your data">
    In the Lark dashboard, open your database and use **Import** to upload the JSON file. This writes the data to your Lark database in the same structure it had in Firebase.
  </Step>

  <Step title="Update your connection URL">
    Change your `databaseURL` from:

    ```
    https://your-project.firebaseio.com
    ```

    to:

    ```
    https://your-lark-project-id.larkdb.net
    ```

    This is the only code change required.
  </Step>

  <Step title="Test">
    Run your app and verify that reads, writes, and subscriptions work as expected. Start with a staging environment or a small percentage of production traffic.
  </Step>
</Steps>

<Tip>You don't have to migrate all at once. Start by pointing a staging environment at Lark, run your test suite, then gradually shift production traffic.</Tip>

## Common gotchas

A few things to double-check before you go live:

* Make sure **Ephemeral mode** is OFF if you want data to persist. Ephemeral mode discards data when all subscribers disconnect. Great for presence systems, not great for your users table.
* If you're using [database routing](/firebase/database-routing) to split data into separate databases, enable **Auto-create** so Lark creates databases on first connect.
* Test your security rules in Lark's rules editor before going live. The syntax is the same, but verify that everything was copied correctly.
* If you have high-frequency data like cursor positions or player movement, consider configuring [volatile paths](/platform/volatile). Firebase SDK clients fully support volatile updates. Lark batches them on the server and delivers them as `PATCH` events that the Firebase SDK handles natively. You just need to define the volatile path patterns in your project settings.

## What's next

<CardGroup cols={2}>
  <Card title="Compatibility notes" icon="circle-check" href="/firebase/compatibility">
    Full list of what's supported and any differences.
  </Card>

  <Card title="Database routing" icon="route" href="/firebase/database-routing">
    Split your single Firebase database into multiple Lark databases.
  </Card>

  <Card title="Firebase Auth with Lark" icon="lock" href="/firebase/auth">
    Keep using Firebase Auth tokens with Lark.
  </Card>

  <Card title="Volatile paths" icon="bolt" href="/platform/volatile">
    Add high-frequency updates to your migrated app.
  </Card>
</CardGroup>
