Skip to main content
Install the React package alongside the core SDK:

Setup

Create a client and pass it to MeridianProvider:
The provider closes the client automatically on unmount. All hooks in the tree share the same connection.

Hooks

useGCounter

usePNCounter

useORSet

Define the schema outside the component so its reference is stable:

useLwwRegister

usePresence

Define the schema outside the component. Pass data to enable auto-heartbeat:
If data is omitted, the hook subscribes without sending a heartbeat (observe-only).

useAwareness

Ephemeral pub/sub for cursors, selections, and real-time UI state. Updates are fanned out in real time but not persisted. Define the schema outside the component for a stable reference:
peers excludes the current client. For an accurate visitor count, combine with usePresence:
See Awareness for full API reference.

useCRDTMap

usePendingOpCount

Returns the number of operations buffered locally, waiting to be sent on reconnect. Use it to build a “syncing” indicator:
The count is non-zero while disconnected with pending writes, and drops to zero once the connection is restored and all ops are flushed.

useMeridianClient

Access the underlying MeridianClient directly:

Requirements

  • React 19+
  • meridian-sdk 0.3+