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

rising-crimson
rising-crimson4/25/2025

Route preloading causing an infinite loop.

I'm running into an issue with route preloading causing an infinite loop. I'm using tanstack start and have a server function fetchSessionUser() that's used in my root route's beforeLoad to get the current user from supabase. When I hover over a <Link to="/teams/create" />, which is located in /_authed/dashboard (route: _authed/teams/create.tsx) , tanstack tries to preload the /teams/create route, and that seems to trigger the root beforeLoad (and therefore the fetchSessionUser() serverFn) repeatedly, leading to an infinite loop of requests like this in the terminal: ServerFn Request: src_routes_authed_tsx--fetchSessionUser_createServerFn_handler...
No description
fascinating-indigo
fascinating-indigo4/25/2025

code splitting file based routing doesn't work for memory history?

1. i try to use autoCodeSplitting: true in vite, it turns out it doesn't work 2. i try to turn off autoCodeSplitting: false then suffix all route with .lazy.tsx, like from "features.tsx to features.lazy.tsx,still doesn't work 3. i try to make it into 2 files, from features.tsx tofeatures/index.tsx and features/index.lazy.tsx 4. i also try to use lazy component: lazy(() =>import("./index.lazy").then((mod) => ({ default: mod.BlogAds }))), still doesn't work ...
clever-tan
clever-tan4/24/2025

Link component not needing params for a dynamic route and working correctly!

Hi. I'm working on a code that renders different sidebar content based on the current route and for that I have the code below. The issue is that I'm using a dynamic Link but without passing a params object to it, but the routing still works. The "To" prop only has the string "/$xyz" and somehow it works! I'm confused on why this is not throwing any errors and is actually routing correctly as from my limited understanding it should not work without passing params. Are the params being inferred here somehow? import { Link, useMatches } from '@tanstack/react-router'...
unwilling-turquoise
unwilling-turquoise4/24/2025

Route typesafety isn't working

All of a sudden I stopped getting any route type safety, I can't see anything that would cause this? Is there any documentation or files I should be checking? Just plain tanstack router...
other-emerald
other-emerald4/24/2025

masked subroute in file based routing

i have an / (index.tsx) route in my tanstack start project. i want to set up a masked route, something like /filters or /?show_filters that shows the filter drawer. however, i want to mask the route. https://tanstack.com/router/latest/docs/framework/react/guide/route-masking i can't seem to figure out how to set it up as a sub route (index.filters.tsx has router set the path to /index/filters)...
vicious-gold
vicious-gold4/24/2025

invalidate data in router context

Hi, I have data loaded and added to the router context to make it available on all pages ``` beforeLoad: async ({ context: { queryClient } }) => ({...
graceful-blue
graceful-blue4/23/2025

Is it possible to render the notFoundComponent inside of my auth only layout?

Please take a look at this adjusted kitchen sink example: https://stackblitz.com/edit/tanstack-router-mg97mijn?file=src%2Froutes%2F__root.tsx My app has a setup like this: - _auth folder for routes only visible after login which has the navbar in the layoutless route - _login folder for routes only visible before login which has the login page layout in the layoutless route ...
adverse-sapphire
adverse-sapphire4/23/2025

vinxi dev & tsr generate different `routeTree.gen.ts`

During CI we use tsr generate to generate the routeTree.gen.ts but it seems like this produces a different routeTree, even if we provide a tsr.config.json. Is there a way to trigger tsr so it provides the same options that the vite plugin does?...
stormy-gold
stormy-gold4/23/2025

TanStack Router node_modules error

Hi everyone, I've just migrated to TanStack Router from React Router and whilst the bulk of the migration went fine I'm having a weird issue with TanStack and typescript. When running typescript check on my project, it picks up a load of issues in tans stack routers .d.ts files. (See attached files) I don't have issues with any other packages so I can't understand how it would be my set up though obviously I can't rule it out....
No description
like-gold
like-gold4/22/2025

Index and auth index routes

Is there a way to have an unauthenticated route / where there is a button to login and once the user is logged in we are still on the / route but it actually loads the /_auth route?
ambitious-aqua
ambitious-aqua4/22/2025

How should I handle layout for login page?

I currently have some universal layouts (nav menu, user profile, etc) inside the root component. These layouts should not be visible unless the user is authenticated. However, a login page will be a descendant of the root component, which will include these layouts. I know I can manually check for authentication inside of root before displaying layouts, but is there another way for only the login page to ignore these layouts?...
vicious-gold
vicious-gold4/22/2025

validateSearch resets router context

Hi, currently I'm trying to use the validateSearch to get search params inside my loader. ```...
No description
sunny-green
sunny-green4/21/2025

Typing a factory function for createFileRoute

Hello everyone, I am trying to create a factory function that returns a createFileRoute with some options predefined, but I am not able to type it correctly with all the generics. Here is an example what I am trying to accomplish: ```ts function customCreateFileRoute(path) { return (options) => {...
afraid-scarlet
afraid-scarlet4/21/2025

Layout route

I have a route /account that has two children so /account/settings and /account/edit. I'm using file based routing: ``` routes/ ā”œā”€ā”€ account/...
wise-white
wise-white4/20/2025

how to utilize the router to navigate ?

hi, do i miss something about utilizing the router.navigate() ? i exported the router from the app.tsx file so i can navigate from anywhere in my app (useNavigate would force me to be in a hook or component, i sometime want to navigate from an action). my is duplicated from doing it the way i do : ``` import ReactDOM from 'react-dom/client' import { RouterProvider, createRouter } from '@tanstack/react-router' import { QueryClient, QueryClientProvider } from '@tanstack/react-query'...
No description
other-emerald
other-emerald4/20/2025

File based pathless wrapping route in folder

I'm trying to figure out if I don't get the docs right. In the following situation with this folder structure: ```routes/ └── app/ └── get-started/ ā”œā”€ā”€ _layout.tsx...
harsh-harlequin
harsh-harlequin4/20/2025

Prevent useBlocker from showing alert on reload

im using useBlocker when i have a dialog open to make the back arrow instead going back in navigation closing the dialog, this works as expected but i dont want the alert on reload when the dialog its open, is there a way to prevent that but still make the back button close the dialog?
No description
eager-peach
eager-peach4/19/2025

How to generate html page for defined routes in build?

Been playing around with Tanstack router + Vite but noticed that even if multiple routes are defined, running build still only generates a single root level html. Given it has route info, I’d expected it to auto add those entry points. How are people achieving a MPA that hands off and behaves as SPA once hydrated?
stormy-gold
stormy-gold4/19/2025

beforeLoad or loader for authentication redirection

Hey everyone, have a pretty simple issue. I am building a react app, and am using the router's authenticated routes + supabase for authentication. I've included a screenshot of my auth.tsx file, and my AuthContext provider. When I navigate between routes, everything works fine. I can only go to protected routes when signed in. However, if I am signed in, and on a protected route, and then I fully reload the page, it brings me back to the login screen. It seems like the beforeLoad function doesn't have the values of the context provider in time on full-reload. However, if I switch the function in __auth.tsx to loader, it works every time, context.auth.isAuthenticated is true. Anybody know why this would be?...
No description
wise-white
wise-white4/19/2025

my first layout

hi guys, im trying to create a layout for my / signin / signup pages but i must have missed something because i have an error that tells me my route is equivalent to '/', here is the file ``` import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/(auth)/_auth')({...