'use cache' pattern with auth
Unanswered
Serengeti posted this in #help-forum
SerengetiOP
Let's say I have the following setup:
If I use 'use cache' anywhere with this setup, I imagine SomeComponent will be cached incorrectly, since there's no params being passed into SomeComponent.
However, if I do the session fetch in page.tsx and pass it down, then that blocks the render for StaticComponent.
Is there a standard pattern for this?
---
page.tsx
function Homepage() {
return <>
<StaticComponent />
<Suspense>
<SomeComponent />
</Suspense>
</>
}
---
some-component.tsx
function SomeComponent() {
const { session } = await auth();
return session ? <p>'Logged in'</p> : <p>'Not logged in'</p>
}
---
If I use 'use cache' anywhere with this setup, I imagine SomeComponent will be cached incorrectly, since there's no params being passed into SomeComponent.
However, if I do the session fetch in page.tsx and pass it down, then that blocks the render for StaticComponent.
Is there a standard pattern for this?