Skip to content

useTable

useTable<T>(table, buildQuery?, options?): UseQueryResult<T[], Error>

Hook for table queries with a simpler API

Type ParameterDefault type
Tany
ParameterTypeDescription
tablestringTable name
buildQuery?(query) => QueryBuilder<T>Optional function to build the query (e.g., add filters)
options?UseFluxbaseQueryOptions<T>Query options including a stable queryKey NOTE: When using buildQuery with filters, provide a custom queryKey that includes the filter values to ensure proper caching.

UseQueryResult<T[], Error>

// Simple query - queryKey is auto-generated from table name
useTable('users')
// With filters - provide queryKey including filter values
useTable('users',
(q) => q.eq('status', 'active'),
{ queryKey: ['users', 'active'] }
)