Skip to main content
The @lark-sh/client package exports several utility functions and constants for working with paths, IDs, and server values.

generatePushId

Generates a unique, chronologically-sortable 20-character ID. The format is identical to the keys produced by DatabaseReference.push(). IDs are ordered by time, so items created earlier sort before items created later when using orderByKey().
Use generatePushId() when you need a key before writing, such as when referencing the key in multiple locations within a single update() call.

ServerValue.TIMESTAMP

A placeholder value that the server replaces with its current timestamp (milliseconds since the Unix epoch) at the time the write is committed. Use this instead of Date.now() to ensure consistency across clients with different clock offsets.
ServerValue.TIMESTAMP is a sentinel object, not an actual number. It is resolved server-side when the write is processed.

normalizePath

Normalizes a database path by removing double slashes, trailing slashes, and leading slashes.

joinPath

Joins one or more path segments with /, producing a normalized path.

getParentPath

Returns the parent path of the given path. Returns an empty string for top-level paths.

getKey

Returns the last segment of a path (the key).

isVolatilePath

Checks whether a given path matches any of the provided volatile path patterns. Volatile paths are used for high-frequency, low-latency data streams such as cursor positions or live indicators.