TanStack DB: queryOnce()

Runs a single, non-reactive query against a collection. Filters, ordering, limits, and joins are pushed to PostgREST where possible. Aggregates like count and sum run on the server. Other operations, like distinct and computed fields, are applied client-side.

Parameters

Examples

Run a one-time query

import { eq } from '@tanstack/react-db'
import { queryOnce } from '@supabase-labs/tanstack-db'

const completed = await queryOnce(
  (q) => q.from({ todo: todos }).where(({ todo }) => eq(todo.completed, true)),
  supabase
)