Next.js Discord

Discord Forum

Server call during build

Answered
Zepeto posted this in #help-forum
Open in Discord
Hi, in my application I fetch my API to retrieve data from a server component, I don't want it to be called at build but only when the client makes a request. Currently I call my promise in the server component and then pass it to the client, where I use react's use hook to retrieve the data.
How can I fix this ? Thanks
Answered by Brokenwind
Use export const dynamic = 'force-dynamic'
View full answer

3 Replies

Up 🙏
Use export const dynamic = 'force-dynamic'
Answer
@Brokenwind Use `export const dynamic = 'force-dynamic'`
Thanks, I hadn't thought of that