TanStack

T

TanStack

TanStack is a community of passionate software engineers striving for high-quality, open-source software for web devs

Join

react-query-questions

solid-query-questions

table-questions

virtual-questions

router-questions

react-charts-questions

ranger-questions

vue-query-questions

svelte-query-questions

bling-questions

form-questions

angular-query-questions

start-questions

db-questions

start-showcase

router-showcase

📣-announcements

noble-gold
noble-gold11/13/2025

How to return extra pagination info from queryFn in TanStack Table?

My API returns something like this: ```ts { data: object[]...
ratty-blush
ratty-blush11/13/2025

Using TanStack DB with Better Auth

Hey everyone, I’m having some trouble understanding how TanStack DB should work together with Better Auth (Organizations). Better Auth already provides built-in methods and hooks like setActiveOrganization, getFullOrganization, and others. When using TanStack DB + ElectricSQL, does this mean I should always update organization data through TanStack DB instead of calling Better Auth directly?...
magic-amber
magic-amber11/13/2025

Collections sometimes get "stuck"

I apologize in advance for this pretty vague-sounding question. First off I've read the docs section on error handling but I'm not sure they apply here. When I observe the network tab in the console I can see the effect of the window gaining visibility because my collection(s) connection(s) ends with NS_BINDING_ABORTED and a new one starts. It seems that when this happens enough times, or I leave the tab for long enough (not sure which), this stops and my collection becomes stuck. I can no longer see new connections being made in the network tab. Doing something on the site (like sending a new message, which should be returned by a messages collection) confirms this - it doesn't show up until I refresh. I feel like I must have set something up wrong somewhere, but I'm not sure what. I'm using the Electric SQL API proxy approach as described in the docs. ...
genetic-orange
genetic-orange11/11/2025

querying on non-primitive fields? (arrays?)

Wondering if this is possible right now -- I initially tried inArray, but it does the opposite of what I want, is column value within an array of values. i'd like 'does columns array of values contain value'...
genetic-orange
genetic-orange11/10/2025

creating an empty collection and ready state

I'm having this issue where i'm basically creating a collection from another one, for instance ```ts const subCollection = createCollection(...
other-emerald
other-emerald11/10/2025

What is the benefit of using an `electricCollection` over an `queryCollection`

In the documentation, this point is not very clear
genetic-orange
genetic-orange11/9/2025

passing arguments to collection?

Is there a pattern for passing a customizable query param that can be passed on to the queryFn? I'm thinking of just having a useMemo'd -> context collection for this, but wondering if there's a different approach already...
like-gold
like-gold11/7/2025

localStorageCollection not saving

Tried a bunch of different things, but can't figure out why my localStorageCollection isn't saving anything in the db. here's my current code: ```ts...
environmental-rose
environmental-rose11/7/2025

How to use Tanstack DB with paginated API

How to use Tanstack DB with paginated REST API? Similar to using useInfiniteQuery
quickest-silver
quickest-silver11/6/2025

Using awaitTxId() after a backend transaction that updates multiple collections

If I have a backend transaction that updates multiple tables (so multiple collections are affected), and I get its txid, would doing this on the client work as expected? ```ts await collection1.utils.awaitTxId(txid) await collection2.utils.awaitTxId(txid)...
rising-crimson
rising-crimson11/3/2025

General disabled state of collections?

I can only find the ´´´status is 'disabled'´´´ in the documentation of live queries: Looking at the following excerpt from the documentation (from the live-queries guide https://tanstack.com/db/latest/docs/guides/live-queries): Conditional Queries...
wise-white
wise-white11/2/2025

React best practices (context vs hook)

Is there an accepted or recommended best practice when it comes to reusing collection/mutation logic with TanStack DB and React? For instance, while migrating my app from Query to DB, I wrote this at first: ```tsx export const useBlock = (id: string) => { const { blocks } = useCollections(); // defines all my collections...
magic-amber
magic-amber10/30/2025

Dev server hot reload removes Electric API route (TanStack Start)

I have a very odd (and very minor) issue that I repeatedly run into. My workflow (using jj-vcs) involves me doing a lot of rebases or other changes to the git log. Very often I find that when I am running the vite dev server while performing these rebase operations, the automatic route tree generated by TanStack Start/Router (I believe - routeTree.gen.ts) will remove exactly one route from my route tree, until I restart the dev server, at which point it regenerates it back in and the file is once again unchanged. That route is consistently the one at const ApiElectricRouteImport = createFileRoute('/api/electric')()...
sensitive-blue
sensitive-blue10/29/2025

Combined Queries Best Practice

Still struggling with the best way to set this up. I have queries from multiple different accounts but for the same data, and I want to unify them into a collection. This seems the simplest, and works: ```typescript const queries = useMemo(() => createQueryDefinitions(accounts), [accountsHash])...
genetic-orange
genetic-orange10/28/2025

What is the "recommended" pattern for using many-to-many relationships using a join table

hey - does anyone have collections that define relationships through join tables (lets say serverId | fileId). At the moment I have dedicated collection for that, and join somehow on the client..
stormy-gold
stormy-gold10/27/2025

obscure getKey type error on collection options

If I have a property in my schema that I have chosen as id for queryCollectionOptions and it is optional then I see a long type error on the entire config object (inside queryCollectionOptions) ```ts const schemaExample = z.object({...
wise-white
wise-white10/26/2025

Multiple mutations to the same collection

Does TanStack DB automatically handle multiple mutations like, for instance, an auto-save input field that sends a mutation onChange? Is it able to cancel previous mutations or at least only keep the latest successful result, or do we have to handle that in application code? If so, are there any examples or best practices? EDIT: Just saw this which looks promising https://github.com/TanStack/db/issues/35 - and makes me think the answer to my question is “no”....
unwilling-turquoise
unwilling-turquoise10/24/2025

Performance Footguns? Slow on prop changes.

I'm noticing FPS dropping as I migrate from useQuery to useLiveQuery. I'm going from tanstack-query useQuery() with deeply nested graphql queries + prop drilling, tanstack-db + electric sql keeping all data synced and local, using useLiveQuery() to join and select exactly the data needed. It seems part of the reason stems from the fact that the data is all there, so when every component on our Dispatch screen is on-screen and then the date prop changes, every single one of them has a change in the where clause at the same instant. A few of the collections have tens of thousands of records, and are joined with 5 others for a given component....
No description
ratty-blush
ratty-blush10/24/2025

SubQuery doesn't seem to work

The locksAgg query returns results results on it's own, but when added as a subquery, I get zero results. Am I doing something wrong with how I am using subqueries? ``` const votes = useLiveQuery((q) => { const locksAgg = q...
fascinating-indigo
fascinating-indigo10/23/2025

Mutations for one-to-many db schema

Hi, I’m wondering if it’s possible to handle mutations outside of the collection but sync after the network call. I’m ok with sacrificing optimistic mutations for simplicity and reduced network calls.