Next.js Discord

Discord Forum

on-demand servercomponents instead of pre-rendered

Answered
Bombay posted this in #help-forum
Open in Discord
BombayOP
Can a server component that has been passed as a prop to a client component
do SSR per request? It seems that I'm only doing build time render or caching data.

the server component gets data from redis
the page shows updated data only after redeploy so I suspect I'm only pre-rendering

How to get server component to render again per request?
basically looking to do appdir version of getServerSideProps

I see that in the docs they want you to use
fetch and disable caching, is this the only way?
I cannot just do
const data = await db.get('example')

?

I do NOT want this data to be cached hard. Just generate the server html on each request. I saw I could do fetch that then does this operation and set no-cache to the fetch

(using next@latest, appdir, deploy to vercel)
Answered by Bombay
ok, found what I needed. Just needed to convert this one
page to force dynamic in page.tsx

actually the docs of next are super good but just full of stuff for a noob like me.
export const dynamic = 'force-dynamic'
View full answer

1 Reply

BombayOP
ok, found what I needed. Just needed to convert this one
page to force dynamic in page.tsx

actually the docs of next are super good but just full of stuff for a noob like me.
export const dynamic = 'force-dynamic'
Answer