jepcd
jepcd
Explore posts from servers
TTCTheo's Typesafe Cult
Created by jepcd on 7/7/2023 in #questions
Does react 18 `cache()` cache across requests?
I'm not sure which way would be better, my use case currently is with next-auth in RSCs, I'm using getServerSession in a lot of server components, and without the cache it makes 2 db queries each time I use it This is what I have now, which works well
export const getCurrentSession = cache(async (): Promise<Session | null> => {
return await getServerSession(authOptions);
});
export const getCurrentSession = cache(async (): Promise<Session | null> => {
return await getServerSession(authOptions);
});
5 replies