tanstack-query
@noy-db/in-tanstack-query·pnpm add @noy-db/hub @noy-db/in-tanstack-queryTanStack Query adapter for noy-db — framework-agnostic (React / Vue / Solid / Svelte).
What it does
Exports plain option factories, not hooks: collectionListOptions,
collectionGetOptions, and collectionQueryOptions each return
{ queryKey, queryFn } ready for any TanStack framework's useQuery();
collectionPutOptions / collectionDeleteOptions return the
useMutation() equivalent. collectionQueryKey(vault, collection, ...extra)
builds the canonical key. bindInvalidation() subscribes to a
Collection's change stream and calls the query client's
invalidateQueries on the matching keys automatically — a drop-in
replacement for ad-hoc invalidateQueries calls scattered through mutation
callbacks. Because these are factories rather than hooks, the same code
works unmodified across every TanStack framework binding.
Usage
import { useQuery } from '@tanstack/react-query'
import { collectionListOptions } from '@noy-db/in-tanstack-query'
const { data } = useQuery(
collectionListOptions('acme', 'invoices', () => vault.collection('invoices')),
)
See also
- in-* family
- tanstack-table — pairs with this for table state
- react —
useCollection/useQuerycover the same case with hooks instead