Firebase Realtime Database limits you to a handful of database instances. If you’re building something with thousands of independent data silos (game rooms, workspaces, documents, sessions), you end up stuffing them all into one giant database under different path prefixes.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.
Option 1: Database-in-subdomain routing
Change your connection URL to put the room/workspace ID in the subdomain. This tells Lark to route each connection to its own database, but your client code and security rules stay exactly the same. Firebase (before):room-abc123-- prefix before -- is the database name. Lark routes this connection to a database called room-abc123 inside your project.
Your client code keeps writing to the same paths:
room-abc123) is technically redundant (it matches the database name), but that’s okay, because it allows your paths, your security rules, and your entire data model to stay identical. The only change is the connection URL.
Inside the room-abc123 database, the data looks like:
Option 2: Use first path segment as database
If you don’t want to change your connection URLs at all, enable Use First Path as Database in your project settings. Lark will look at the first segment of every path, route it to a database with that name, and strip that segment from the path. Your connection URL points at the project, just like Firebase:room-abc123) and uses it as the database name. The write lands at /players/alice in a database called room-abc123.
Your client code stays identical to what you had on Firebase. No connection URL changes, no path changes. The routing happens transparently on the server.
When to use this: When you want the benefits of separate databases without changing any client code or connection URLs. This is the fastest migration path.
Option 3: Keep everything in one database
You don’t have to split anything. Lark is happy to run a single large database with all your data in it, just like Firebase did.default. This matches Firebase’s standard behavior: one namespace, one database.
When to use this: When you’re migrating from Firebase and want zero changes beyond the connection URL. This works fine and is a perfectly valid approach.
Comparing the three options
| Option 1: Subdomain | Option 2: First path | Option 3: One database | |
|---|---|---|---|
| Connection URL changes | Yes, include room ID in subdomain | No | No |
| Client code changes | No, same paths | No, same paths | No |
| Security rules changes | No, same structure | Yes, remove the top-level wildcard | No |
| Separate databases | Yes | Yes | No |
| Write contention | Per-room (isolated) | Per-room (isolated) | Shared across all rooms |
| Data structure | Redundant first segment | Clean (first segment stripped) | Same as Firebase |
Setting it up
- In the Lark dashboard, go to your project’s Settings.
- Enable Auto Create so databases are created on first connection.
- If using Option 2, enable Use First Path as Database.
- If using Option 1, update your client code to include the database name in the subdomain.
- If using Option 2, update your security rules to remove the top-level path segment.

