Next.js Discord

Discord Forum

Is it possible to dynamically use force-dynamic?

Unanswered
Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
My preview build should have always cache disabled:
if (process.env.SB_SSR === 'draft') { export const dynamic = 'force-dynamic'; } or is there a better option?

3 Replies

Pacific sand lance
export const dynamic = process.env.SB_SSR === 'draft' ? 'force-dynamic' : '...';
maybe sth like that
idk if turbopack inlines non-exposed env vars tho