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

united-yellow
united-yellow6/2/2025

React Native - React Query re-fetches on all mounted screen after query invalidation

In React Native, screens don’t unmount when navigating between them. So if a user moves through, say, 10 screens, each one remains mounted. Because of this, any time I invalidate a query (which I do when changes are detected since the app is local-first and uses a SQL database), every screen that’s still mounted re-fetches its data immediately — even if it’s not in focus. This creates a cascade of React Query invalidations and database queries. As a workaround, I’ve started passing a subscribed boolean based on whether the screen is in focus, to prevent re-fetching when it’s not. ...
mere-teal
mere-teal5/30/2025

Typescript DX assistance "request"?

Hey guys, I'm relatively new to this library. While I find it's mental model exciting, and I really like inferred types, I feel like core Typescript DX is really strange I know that rules recommend don't insert much screenshorts, but I promise, they're not context-overwhelming Here's what I mean by TS DX: ...
No description
stormy-gold
stormy-gold5/30/2025

Query Return Type when using `select`

Hi all. I guess this is more of a TS question than query related but I've been wondering how to best practice the return type when using select on data retrieval? My query calls the API to get a data set which has it's own type - but I've also built in a parsing flag for the data set which returns another type if true....
ratty-blush
ratty-blush5/26/2025

Need Assist

Opportunity: Be Our Agency's Representative, Hi there! I hope you're doing great! We're a growing software development agency looking for a reliable partner in Europe or North America (US, Canada, Mexico) to help us expand our reach. ...
ratty-blush
ratty-blush5/26/2025

find Project

Hi, My name is James, I'm a Senior FullStack Developer with over 8 years of experience developing and maintaining high-performance web applications. I specialize in development with a strong focus on modern JavaScript frameworks like React, Vue.js, Angular and Larlabel. After graduating unversity ,while working in a few companies, learned how code for maintainable, scalable and portable program, so I’m passionate about writing clean, maintainable code, implementing best practices, and mentoring junior developers to help them grow technically and professionally....
correct-apricot
correct-apricot5/26/2025

Tanstack with next server action

Hey everyone! I’m using TanStack Query + Next.js and want to make sure I’m doing this the best way. Here’s what I’m doing: ...
rare-sapphire
rare-sapphire5/25/2025

useQuery not using stale data why?

I have the following code in my app export const clientPersister = createSyncStoragePersister({ storage: clientStorage }); const queryClient = new QueryClient({ defaultOptions: {...
fascinating-indigo
fascinating-indigo5/24/2025

Unable to clear persisted queries

I'm using the experimental_createQueryPersister to persist query data in indexedDB. Unlike PersistQueryClientProvider and createAsyncStoragePersister which deletes the persisted data when queryClient.clear() is triggered, the data is not deleted when using the experimental persister. Is there a solution to this while maintaining the experimental persister....
stormy-gold
stormy-gold5/23/2025

Cypress tests failing after upgrading from react-query v3 to v5

I'm trying to upgrade to v5 of react-query, but I'm experiencing a weird issue where some of my e2e Cypress tests are no longer working. In these tests I am mocking data returned from an API. Running the tests with breakpoints, I can see in the network tab that the mocked data is correctly appearing in the response. However once the useQuery completes, the component doesn't re-render so the data variable is undefined Here's vaguely what my code looks like: ``` const { data } = useQuery({...
xenial-black
xenial-black5/21/2025

nextjs hydration error useQuery & useMutation

I am fetching data server side via a server action. I then pass this data to a client component. Within the client component I pass the data as initial data to useQuery. Then use the useQuery data within a table. ...
No description
sensitive-blue
sensitive-blue5/21/2025

NextJS Streaming vs TanStack Streaming

Can I get a short comparison between these two? Consider a NextJS app that is kinda a dashboard, is there any specific differences that worth noting? I already read these: https://tanstack.com/query/latest/docs/framework/react/guides/advanced-ssr#streaming-with-server-components...
national-gold
national-gold5/19/2025

Does useQuery run twice in strict mode? Because for me it doesn't

I'm running this query: ```ts const { data } = useQuery({ queryKey: ['workoutSessions'], queryFn: () => fetchWorkoutSessions(auth.userId),...
foreign-sapphire
foreign-sapphire5/19/2025

Porting existing Api structure to queryOptions

Hi! I have an existing structure in my codebase that's been around for a few years and is used everywhere internally. It is automatically generated from the backend and has a call structure like Api.Settings.Foo.read({ fooId })....
genetic-orange
genetic-orange5/18/2025

Prerendering error

I'm currently encountering an error when trying to build my application. My application is nextJS version 15 using app router: The error I'm getting: ```javascript...
ambitious-aqua
ambitious-aqua5/18/2025

Multiple query keys loading the same data [ANSWERED]

Suppose I have the following screens: * All posts (GET /posts) * User's posts (GET /users/{userId}/posts) * Post details (GET /posts/{postId}) ...
fair-rose
fair-rose5/16/2025

How to Delay Queries Until After User Provisioning?

Hi everyone, I'm new to TanStack Query (v5) and currently integrating it into a React frontend that uses MSAL.js for authentication with Azure AD. After users successfully log in via MSAL, I need to call a POST /users/provision endpoint to create or update them in the backend. This provisioning step fetches role information, ensures the user is stored in the DB, and returns their data. Only after that should the rest of my app start loading anything else. The issue is that React Query hooks like useCurrentUser, useSmsCredits, useSmsLogs etc. run immediately and make requests before provisioning is complete. This causes race conditions and unauthorized errors, especially when it's the user’s first login....
optimistic-gold
optimistic-gold5/16/2025

Query Cache methods find and findAll docs

Hello, I was checking the documentation for QueryCache and I believe that it might not be updated with the newer v5 requirements. Documentation page mentions that both find and findAll expect a queryKey as first argument https://tanstack.com/query/v5/docs/reference/QueryCache/#querycachefind...
No description
continuing-cyan
continuing-cyan5/16/2025

`HydrationBoundary` won't pass **some** data

in my query config i have several keys ```ts export const queryKeys = { cookies: ['cookies'], entity: (id: string | undefined) => ['entity', id],...
absent-sapphire
absent-sapphire5/16/2025

Mutation not changing `isPending` back

We got this query hook: ```tsx function useDeleteProjectStageTemplate({ editMode, removeStageTemplate,...