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

other-emerald
other-emerald10/20/2025

What is the proper pattern for capturing a one to many (1:*) relationship with useLiveQuery?

Let's say you have a list collection and a tasks collection. One collection has many tasks. How can I return something like the following from useLiveQuery? ```typescript { ...list,...
extended-salmon
extended-salmon10/17/2025

Is it possible to useLiveSuspenseQuery?

I am converting some useSuspenseQuery to using tanstack/db and would like to mirror the same suspense behavior so that react will suspend at least until the query's initial loading is complete. My AI coding helper suggested I add an options object to the useLiveQuery(query, { suspense: true }) -- but this is not a real option! actually I can't find the word "suspense" or "suspend" anywhere in the documentation at all. As a backup I have a route loader that is doing an await, like this:...
metropolitan-bronze
metropolitan-bronze10/16/2025

Best Practice for combining queries of same object type for a collection

Per the useLiveQuery Optimization, I have multiple queries across multiple accounts (for example purposes lets say 9) that all return arrays of the same object type. Is it better to create 9 collections for each source and stitch those together with a live query, or make a single collection that pulls the data together as part of its Tanstack Query definition. I'm more inclined to the latter and route the CRUD update hooks directly via one collection rather than having to have a map to find which one it came from and act on that collection....
metropolitan-bronze
metropolitan-bronze10/16/2025

useLiveQuery optimization: collection or collection options?

Say I just want a simple view on my Tanstack Query Collection (which in on itself is a dependent query). Is it better to create the collection first, memoize it, and then pass that to useLiveQuery, or should I just pass the full createCollection with options to useLiveQuery and it will ensure I don't get a dupe if the options are the same? Just trying to minimize work on re-renders or worse, end up with multiple inconsistent collections. Example:...
foreign-sapphire
foreign-sapphire10/16/2025

How to conditionally call useLiveQuery

I have the following code: ``` const useElectricChatsByReportId = (reportId: string | null) => { const org = useCurrentOrg();...
gradual-turquoise
gradual-turquoise10/14/2025

Should type inference detect `where` clause filters?

For example, if my collection has an attribute that could be string | undefined, but I have a where condition of not(isUndefined(item.attribute)) is it desirable and possible that the type inference of items in the returned dataset is just string? I've found several situations where that would be helpful in my codebase, but open to the possibility that this should not work that way....
like-gold
like-gold10/14/2025

How to setup debouncing correctly?

I've seen this feature proposal for Serialized Transaction Queuing Utility but was wondering if you had any recommendation to set debounced updates properly in the mean time? I tried writing a wrapper over onUpdate that associate an async debouncer from Tanstack Pacer with the onUpdate call using the mutation key (I only care for the first mutation in the transaction), but it kinda breaks the "reconciliation" with previous refetches. My use cases are inputs like text boxes, sliders, are really any kind of input that needs optimistic updates with a debounced persistence....
optimistic-gold
optimistic-gold10/12/2025

basic vue-db setup typescript issue

Hello there, I'm just trying to get a very basic setup to play nice with typescript. this is the script part of a vue SFC: ```typescript...
No description
other-emerald
other-emerald10/10/2025

Long term persistence strategy

What is the best way to use TanStack DB so that the local content is preserved across sessions and tabs? Scenario - 40 MB of data needed from DB to operate offline (approx.) - Re-downloading this every time is expensive. Ideally, data stored on device is used first and updates since last sync are applied...
unwilling-turquoise
unwilling-turquoise10/10/2025

Electric Replica Identity

electric-1 | 00:32:34.930 pid=<0.3276.0> [error] Schema reconciliation failed: ** (Electric.DbConfigurationError) Database table "public.users" does not have its replica identity set to FULL
electric-1 | 00:32:34.930 pid=<0.3276.0> [error] Schema reconciliation failed: ** (Electric.DbConfigurationError) Database table "public.users" does not have its replica identity set to FULL
just wondering if there are plans to support non-full (ie default) replica identities in the future? or is this requirement by design?...
conscious-sapphire
conscious-sapphire10/6/2025

How to wait for 'clean' queryCollection

This is related to this scenario here: https://discord.com/channels/719702312431386674/1369767025723052134/1423904416272089089. I'm creating a row if it does not already exist. If it does exist, the API will return an error, and the desired behaviour is that it refetches to sync with the query state. However, at this point the change gets reverted, triggering the same mutation to run again. I'm wondering if there's a way to wait for the collection to be 'clean': that is that there was a refetch and no errors occured since....
harsh-harlequin
harsh-harlequin10/5/2025

Best practices for Infinite lists with TanStackDB

Hey guys, sorry if this question has already been answered but I haven't found anything concrete in discord history. Is there a best practice solution for implementing an infinite list with TanStack DB and electricSQL? Based on my reading, it looks like there isn't a TanStackDB liveQuery that is similar to useInfiniteQuery .I'm going to use orderBy, limit and offset but is there anything else you'd recommend when implementing an infinite list with TanStackDB?...
rare-sapphire
rare-sapphire10/4/2025

question about persistance

Does the default electric sql collection has indexdb based persistance support by default? I am seeing that it syncs everything from server on every page refresh and uses nothing from local. Can someone please clear this doubt?
flat-fuchsia
flat-fuchsia10/4/2025

`await tx.isPersisted.promise` is not working

I've been using tanstack/db for about a month now, and the await tx.isPersisted.promise has stopped working at some point. I don't remember which version, but I'm currently on 0.1.27 and it doesn't work....
No description
harsh-harlequin
harsh-harlequin10/3/2025

Tanstack Query Dependencies

Hello, I've been wanting to use Tanstack DB in my project which also uses Tanstack Router and Tanstack Query, but I've been struggling to figure out how to structure createCollection with queries that have a dependency on a different query. In particular, I use versioned endpoints to manage CDN caching, so most of the queries I want to use to create collections depend on a db-version query which has to run before them. This creates a problem since it seems like collections really want to be defined in the global namespace (so they can be used directly inside live queries), but it isn't possible to encapsulate this dependency chain with queryCollectionOptions since there's no way for the db version to get passed from the db-version query into the statically defined query inside queryCollectionOptions. ...
stormy-gold
stormy-gold10/3/2025

type narrowing in live queries

Hey all! I've got a series of events which I'd like to filter out (and type narrow) in order to produce aggregates. Here's what I have so far: ```typescript export const eventCollection = createCollection( localOnlyCollectionOptions({...
unwilling-turquoise
unwilling-turquoise10/3/2025

Safari refusing to use HTTP/2

Bit of a long shot but if anyone has any ideas, please let me know... I have a tanstack start/db/electric sql setup with an API proxy from the start server -> electric sql, and caddy reverse proxying the start server. Caddy is serving an internal tailscale domain (ts.net) as the route for my dev server, which means it gets HTTPS automatically. On desktop firefox and chrome this setup is enough to get even http/3 connections, while safari on desktop and iOS are refusing to use anything except 1.1, which leads to the now-familiar 6-connection limit issue. If anyone has any ideas please let me know! I suspect tailscale somehow has smth to do with it but I have no other leads....
stormy-gold
stormy-gold10/1/2025

typing in helpers in db-ivm

Hey! I'm using db-ivm to aggregate events from an event-sourced system for display. Working great so far! I've noticed a lot of boilerplate around sorting and filtering, though, and so I've tried to make myself a helper: ```typescript export function build<Event extends { timestamp: number }, Out, Key extends string | number>( builder: (events: Event[]) => Out | null | undefined,...
unwilling-turquoise
unwilling-turquoise9/29/2025

Understanding how temporary IDs are used

I've got a function like ``` export function generateTempId(): number { return -Math.floor(Math.random() * 1000000) + 1...
adverse-sapphire
adverse-sapphire9/26/2025

Creating multiple collections from a single query?

Hiya folks! I'm curious: we're looking at adding batched rpc routes for a given page that return all data required to render said page in a single request. Is there a way to create/update multiple collections from a single query?