r/TanStackStart • u/dk_void_ • Jan 11 '26
NEED HELP IN TANSTACK START MIDDLEWARE
i am trying tanstack start i used better auth create auth middleware , in middleware i pass the context of session and used the middleware in profile route is there any way use the middleware context data in profile route or i just use better auth client side hook
1
Upvotes


2
u/hyperi0nt Jan 12 '26
Do you have to use a middleware? I use session like this (do not insist this is a good solution, just as an example).
and in a "wrapper" route like this
And in any nested component I can use:
Or just access a route's context using any method you like.
2
u/[deleted] Jan 12 '26
and:
export const Route = createFileRoute('/_protected')({
component: RouteComponent,
beforeLoad: async () => {
const session = await getUser()
return { session }
},
loader: ({ context }) => {
console.log(context.session)
},
})
2
u/tserdeiro Jan 13 '26
Yo lo uso de esta manera, tal vez te sirve:
y la función 'getSession':