Next.js Discord

Discord Forum

Server rendered page become static rendered after build

Answered
Fire ant posted this in #help-forum
Open in Discord
Fire antOP
I have route
/home
which is server component. In dev mode, it fetches api data from server fetch, which is working.
After build next, the
/home
page become static rendered and not server rendered? Why?
next 14.0.5-canary.59
Answered by Fire ant
adding
export const dynamic = 'force-dynamic';
fixed it
View full answer

7 Replies

@joulev add `export const revalidate = 0` to your page
Fire antOP
will try out
Got this error on main static page route
"/"

TypeError: e[o] is not a function
    at t (D:\nextjs\.next\server\webpack-runtime.js:1:127)
    at F (D:\nextjs\node_modules\.pnpm\next@14.0.5-canary.59_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:94693)
    at j (D:\nextjs\node_modules\.pnpm\next@14.0.5-canary.59_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:93244)
    at rP (D:\nextjs\node_modules\.pnpm\next@14.0.5-canary.59_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:33905)
    at nL (D:\nextjs\node_modules\.pnpm\next@14.0.5-canary.59_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:62423)
    at nB (D:\nextjs\node_modules\.pnpm\next@14.0.5-canary.59_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:67657)
    at nF (D:\nextjs\node_modules\.pnpm\next@14.0.5-canary.59_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:66824)
    at nL (D:\nextjs\node_modules\.pnpm\next@14.0.5-canary.59_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:64990)
    at nB (D:\nextjs\node_modules\.pnpm\next@14.0.5-canary.59_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:67657)
    at nM (D:\nextjs\node_modules\.pnpm\next@14.0.5-canary.59_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:58551)

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: e[o] is not a function
Fire antOP
found solution
Fire antOP
adding
export const dynamic = 'force-dynamic';
fixed it
Answer
hmm weird that revalidate: 0 didnt work but yes force-dynamic is an alternative