Skip to main content

Lark SDK

The Lark SDK (@lark-sh/client) is the official JavaScript/TypeScript client for Lark databases. It gives you real-time data synchronization, offline support, and a modern developer experience in a lightweight package.

Lark SDK Features

The entire SDK is ~20KB gzipped. Subscriptions return an unsubscribe function directly, so there’s no need to track callbacks or call a separate off() method. This plays nicely with React’s useEffect cleanup, Vue’s onUnmounted, and any other framework lifecycle pattern.
import { LarkDatabase } from "@lark-sh/client";

const db = new LarkDatabase("my-project/my-database", { anonymous: true });

// on() returns an unsubscribe function — no need to await connect() first
const unsubscribe = db.ref("scores").on("value", (snapshot) => {
  console.log(snapshot.val());
});

// Clean up when you're done
unsubscribe();
The SDK connects over WebSocket by default. You can opt in to WebTransport (HTTP/3) for lower latency and better multiplexing in supported browsers by setting transport: 'auto'. Ephemeral data like cursor positions, typing indicators, and player coordinates can flow through volatile paths, which are high-frequency updates that skip persistence for maximum speed. Every method, option, and return value is fully typed with TypeScript.

Installation

npm install @lark-sh/client
Or with your preferred package manager:
yarn add @lark-sh/client
pnpm add @lark-sh/client

Platform support

The Lark SDK works in browsers and Node.js. Both CommonJS and ESM builds are included, and your bundler or runtime will pick the right one automatically.
PlatformSupport
Modern browsers (Chrome, Firefox, Safari, Edge)Full support
Node.js 18+Full support
React NativeFull support
DenoESM import

Package

Everything you need is in a single package:
import { LarkDatabase, ServerValue } from "@lark-sh/client";
If you’re migrating from Firebase v8, the SDK also ships a compatibility layer at @lark-sh/client/fb-v8. See the Firebase v8 compatibility page for details.

What’s next

Quickstart

Connect, write, read, and subscribe in under five minutes.

Connecting

Connection options, transports, and lifecycle events.

Writing data

Set, update, remove, push, and multi-path writes.

Subscriptions

Listen for real-time changes with different event types.