TanStackT
TanStack16mo ago
16 replies
uncertain-scarlet

Best practices for combining tanstack router context + tanstack query [React, Typescript]?

Howdy,

I am building an app that tries to implement authentication without using any stored state on the frontend (no localestorage/session). My project uses tanstack router and tanstack query so I am a bit confused how I can combine both to make my life easier?

I am currently setting user/setUser as tantack router context and setting user on login/signup with a cookie.

I could also use setQueryData for user and pass queryClient as tanstack context.

any preference or ideas here? I will also need to fetch to grab user everytime I open the app since I'm not using localestorage.
Was this page helpful?