T
TanStack11mo ago
xenial-black

How to do authenticated routes in `start` like this example?

https://github.dev/tanstack/router/tree/main/examples/react/authenticated-routes
function InnerApp() {
const auth = useAuth()
return <RouterProvider router={router} context={{ auth }} />
}

function App() {
return (
<AuthProvider>
<InnerApp />
</AuthProvider>
)
}
function InnerApp() {
const auth = useAuth()
return <RouterProvider router={router} context={{ auth }} />
}

function App() {
return (
<AuthProvider>
<InnerApp />
</AuthProvider>
)
}
I tried to pass the auth object to the StartClient, however, context.auth is always undefined in beforeLoad function. Is this even possible to achieve in start? As it magically passes client side data to server's beforeLoad function's arguments?
2 Replies
xenial-black
xenial-blackOP11mo ago
I am using supabase to do the authentication. I followed the supabase auth example, but it is really slow in my use case, when the user switches between protected tabs, it has to do the authentication checks every time (make requests to the supabase server).
TanStack | High Quality Open-Source Software for Web Developers
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.
From An unknown user
From An unknown user
xenial-black
xenial-blackOP11mo ago
I have tried disable ssr for routes and the router. But it does not help

Did you find this page helpful?