TanStack Query if I need session in call?
I am using NextJS app router. I thought I could use TanStack Query following the Advanced SSR guide, however it seems that if I need the session, I cant have useQuery or queryClient.prefetchQuery() call my function because if its server side, I won't have access. Any ideas?
Using Next Auth, getServerSession, or useSession.
3 Replies
robust-apricot•17mo ago
lol
i think i asked this Q recently
prefetchQuery doesnt give u the data
but if u need it
robust-apricot•17mo ago
QueryClient | TanStack Query Docs
QueryClient
The QueryClient can be used to interact with a cache:
robust-apricot•17mo ago
fetchQuery
fetch, store in cache and get the data
u can then pass it around as props