Can we use expressions (like 7 * 24 * 3600) for the revalidate parameter?
Answered
Siamese Crocodile posted this in #help-forum
Siamese CrocodileOP
Hi everyone,
I was wondering if it's okay to use expressions like 7 * 24 * 3600 for the revalidate value in Next.js. I’ve tried it, and it actually works for me.
But the official docs say that we can only use fixed numbers—not expressions. Maybe they just haven’t updated that part yet?
https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#revalidate
Has anyone else noticed this or knows if it's officially supported?
I was wondering if it's okay to use expressions like 7 * 24 * 3600 for the revalidate value in Next.js. I’ve tried it, and it actually works for me.
const germany = await getCountryByCode(
{ code: "GER", fields: ["name", "capital"] },
{ next: { revalidate: 7 * 24 * 3600 }, cache: "force-cache" }
);
But the official docs say that we can only use fixed numbers—not expressions. Maybe they just haven’t updated that part yet?
https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#revalidate
Has anyone else noticed this or knows if it's officially supported?
Answered by Asian black bear
That section you linked refers to the
export const revalidate = ...
route segment config, not for parameters passed to fetch
. The time needs to be statically analyzable only for the route segment config.2 Replies
Asian black bear
That section you linked refers to the
export const revalidate = ...
route segment config, not for parameters passed to fetch
. The time needs to be statically analyzable only for the route segment config.Answer
@Asian black bear That section you linked refers to the `export const revalidate = ...` route segment config, not for parameters passed to `fetch`. The time needs to be statically analyzable only for the route segment config.
Siamese CrocodileOP
Thank you very much. I thought it is for revalidate fetch option