Overview
useTable is the React/React Native hook for a custom table’s rows, backed by RTK Query against the /db surface. It returns the current page of rows plus loading/refetch state, query controls, and row CRUD actions. The query knobs (page, limit, sort, filters, includeDeleted) are stored in the tables Redux slice keyed by table name, so multiple consumers of the same table share one view.
See Custom Tables — Overview for a guide, and Custom Tables for the feature concept.
Usage Example
Parameters
The logical custom-table name (without the
custom_ prefix). Must be stable across renders.Optional initial view — any of
page, limit, sortBy, sortDir, filters, includeDeleted. Used to seed the stored view the first time this table is read.Return Values
The current page of rows.
Pagination metadata (
page, pageSize, totalPages, totalItems, hasMore), or null before the first load.true while the current query is in flight.The query error, if any.
Re-runs the current query.
The current stored view:
{ page, limit, sortBy, sortDir, filters, includeDeleted }.Merge-updates the stored view.
Changes the current page.
Replaces the filter clauses (and resets to page 1). Each clause is
{ column, operator, value }; operators are eq, ne, gt, gte, lt, lte, in, contains, like, isNull, AND-combined.Sets the sort column/direction (and resets to page 1).
On a paranoid table, toggles whether soft-deleted rows are included (resets to page 1).
Inserts a row. Managed columns (
id/createdAt/updatedAt/deletedAt) are server-set and rejected from the body.Updates a row;
updatedAt is bumped automatically on a timestamped table.deleteRow
(rowId: string, opts?: { force?: boolean }) => Promise<{ deleted: boolean; soft: boolean }>
Deletes a row. Soft-deletes on a paranoid table by default; pass
{ force: true } to hard-delete.Clears
deletedAt on a soft-deleted row (paranoid tables only).
