createSyncClientHooks
createSyncClientHooks<
TRegistry>():object
Defined in: create-hooks.tsx:87
Creates a set of React hooks and a context provider bound to a specific
SyncTableRegistry type. Call this once at the module level in your app:
export const { SyncClientProvider, useSyncClient, useLiveRows, useLiveDrizzleRows, useLiveQueryRaw } = createSyncClientHooks<typeof mySyncRegistry>();Type Parameters
Section titled “Type Parameters”TRegistry
Section titled “TRegistry”TRegistry extends SyncTableRegistry
Returns
Section titled “Returns”SyncClientProvider
Section titled “SyncClientProvider”SyncClientProvider: (
__namedParameters) =>Element
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”children
Section titled “children”ReactNode
client
Section titled “client”SyncClient<TRegistry> | null
Returns
Section titled “Returns”Element
useLiveDrizzleRow
Section titled “useLiveDrizzleRow”useLiveDrizzleRow: <
TRows>(buildQuery,deps,options?) =>object
Type Parameters
Section titled “Type Parameters”TRows extends readonly unknown[]
Parameters
Section titled “Parameters”buildQuery
Section titled “buildQuery”(client) => DrizzleSqlBuilder<TRows>
DependencyList
options?
Section titled “options?”keepAliveMs?
Section titled “keepAliveMs?”number
ready?
Section titled “ready?”boolean
Returns
Section titled “Returns”object
error:
Error|null
hydrating
Section titled “hydrating”hydrating:
boolean
loading
Section titled “loading”loading:
boolean
row:
TRows[number] |null
useLiveDrizzleRows
Section titled “useLiveDrizzleRows”useLiveDrizzleRows: <
TRows>(buildQuery,deps,options?) =>LiveRowsState<TRows>
Reactive query using a Drizzle select builder. The builder is re-created
whenever deps changes (same contract as useEffect). pgxsinkit scans the compiled SQL and
auto-activates any lazy relation the query reads — anywhere it appears (FROM, JOIN, subquery,
WHERE) — before subscribing. use (see useLiveQueryRaw) is an optional pre-activation hint,
not a requirement (ADR-0021).
const { rows } = useLiveDrizzleRows( (c) => c.drizzle.select().from(c.views.todos).orderBy(c.views.todos.createdAtUs), [],);// rows is fully typed from the view definition — no casts neededType Parameters
Section titled “Type Parameters”TRows extends readonly unknown[]
Parameters
Section titled “Parameters”buildQuery
Section titled “buildQuery”(client) => DrizzleSqlBuilder<TRows>
DependencyList
options?
Section titled “options?”keepAliveMs?
Section titled “keepAliveMs?”number
ready?
Section titled “ready?”boolean
Returns
Section titled “Returns”LiveRowsState<TRows>
useLiveQueryRaw
Section titled “useLiveQueryRaw”useLiveQueryRaw: <
TRows>(args) =>LiveRowsState<TRows>
The reactive query for a builder that embeds a raw sql fragment (ADR-0021): use names the lazy
relations it reads that the compiled-SQL scan can’t see (a bare identifier inside raw SQL), so they
are guaranteed activated before it subscribes. The non-live counterpart of
client.queryRaw({ use, build }). Pure-Drizzle reads use useLiveDrizzleRows / client.query((c) => …),
which auto-detect every relation and need no use.
const { rows, hydrating } = useLiveQueryRaw({ use: ["archive"], build: (c) => c.drizzle.select().from(archiveTable).where(inArray(archiveTable.id, recentIds)), deps: [recentIds],});Type Parameters
Section titled “Type Parameters”TRows extends readonly unknown[]
Parameters
Section titled “Parameters”(client) => DrizzleSqlBuilder<TRows>
DependencyList
keepAliveMs?
Section titled “keepAliveMs?”number
ready?
Section titled “ready?”boolean
readonly SyncTableName<TRegistry>[]
Returns
Section titled “Returns”LiveRowsState<TRows>
useLiveQueryRawRow
Section titled “useLiveQueryRawRow”useLiveQueryRawRow: <
TRows>(args) =>object
Type Parameters
Section titled “Type Parameters”TRows extends readonly unknown[]
Parameters
Section titled “Parameters”(client) => DrizzleSqlBuilder<TRows>
DependencyList
keepAliveMs?
Section titled “keepAliveMs?”number
ready?
Section titled “ready?”boolean
readonly SyncTableName<TRegistry>[]
Returns
Section titled “Returns”object
error:
Error|null
hydrating
Section titled “hydrating”hydrating:
boolean
loading
Section titled “loading”loading:
boolean
row:
TRows[number] |null
useLiveRow
Section titled “useLiveRow”useLiveRow: <
TRow>(query,options?) =>object
Type Parameters
Section titled “Type Parameters”TRow extends Record<string, unknown> = Record<string, unknown>
Parameters
Section titled “Parameters”string
options?
Section titled “options?”params?
Section titled “params?”readonly unknown[]
pglite?
Section titled “pglite?”ClientPGlite
ready?
Section titled “ready?”boolean
Returns
Section titled “Returns”object
error:
Error|null
loading
Section titled “loading”loading:
boolean
row:
TRow|null
useLiveRows
Section titled “useLiveRows”useLiveRows: <
TRow>(query,options?) =>object
Reactive raw-SQL query. This is the unguarded escape hatch: it does not participate in the
lazy-relation safety net (ADR-0021) — a raw string is not parameterised/quoted predictably, so a
lazy relation referenced here will read empty/stale unless you client.ensureSynced([...]) first.
Prefer useLiveDrizzleRows / useLiveQueryRaw for anything touching lazy relations.
Type Parameters
Section titled “Type Parameters”TRow extends Record<string, unknown> = Record<string, unknown>
Parameters
Section titled “Parameters”string
options?
Section titled “options?”params?
Section titled “params?”readonly unknown[]
pglite?
Section titled “pglite?”ClientPGlite
Explicit PGlite instance — overrides the context client. Useful in tests or multi-db scenarios.
ready?
Section titled “ready?”boolean
Returns
Section titled “Returns”object
error:
Error|null
loading
Section titled “loading”loading:
boolean
rows:
TRow[]
useMutationList
Section titled “useMutationList”useMutationList: (
options?) =>object
Reactive filtered mutation detail list (client.mutations.subscribe): normalized journal rows across
every writable table, filtered by table / entityKey / statuses / limit, ordered newest-first.
Route/feature-scoped — mount it where a diagnostics view is open, not app-wide (prefer
useMutationSummary for a global indicator). No hydrating flag (journals are local).
Parameters
Section titled “Parameters”options?
Section titled “options?”MutationListOptions<TRegistry> & object
Returns
Section titled “Returns”object
error:
Error|null
loading
Section titled “loading”loading:
boolean
rows:
MutationDetail[]
useMutationSummary
Section titled “useMutationSummary”useMutationSummary: (
options?) =>object
Reactive registry-wide mutation summary (client.mutations.subscribeSummary): per-status counts across
EVERY writable journal, folded to one MutationSummary. ONE subscription drives a global sync
indicator — no hydrating flag, because journals are local and never network-hydrated. Cheap enough to
mount permanently (ADR-0040 dedup: one registration regardless of subscriber count).
Parameters
Section titled “Parameters”options?
Section titled “options?”ready?
Section titled “ready?”boolean
Returns
Section titled “Returns”object
error:
Error|null
loading
Section titled “loading”loading:
boolean
summary
Section titled “summary”summary:
MutationSummary
useSyncClient
Section titled “useSyncClient”useSyncClient: () =>
SyncClient<TRegistry>
Returns
Section titled “Returns”SyncClient<TRegistry>