Firebase v8 compatibility layer
If you’re migrating from Firebase Realtime Database v8 (the firebase/database namespaced API), the Lark SDK includes a compatibility layer that matches the Firebase v8 API surface. This lets you switch to Lark without rewriting your subscription patterns.
Installation
The compatibility layer ships as a sub-package inside @lark-sh/client. No extra installation needed.
Key difference: on() and off()
The biggest API difference between the modern Lark SDK and the Firebase v8 compatibility layer is how subscriptions work.
Modern Lark SDK: on() returns an unsubscribe function:
Firebase v8 compatibility: on() returns the callback, and you use off() to stop listening:
Side-by-side comparison
Context parameter
The Firebase v8 API supports a context parameter for binding this inside your callback. The compatibility layer supports this too:
When to use the compatibility layer
Use @lark-sh/client/fb-v8 when:
- You’re migrating a Firebase v8 codebase and don’t want to rewrite every
on()/off() call pattern.
- You have shared libraries or utilities that expect the Firebase v8 subscription API.
- You need
off() semantics like removing all listeners for a specific event type with a single call.
Use the modern @lark-sh/client when:
- You’re starting a new project. The unsubscribe-function pattern is cleaner and less error-prone.
- You’re using React, Vue, or Svelte. Framework cleanup hooks work naturally with unsubscribe functions.
- You want the simplest API. No need to track callback references or worry about matching the right callback in
off().
You can use both imports in the same project during a migration. They share the same underlying connection, so you won’t create duplicate connections.
Migration path
If you decide to migrate from the compatibility layer to the modern API later, the changes are mechanical:
The rest of the API (set(), update(), remove(), once(), transaction(), queries, OnDisconnect) is identical between the two.