For this question I have created the following demo Next.js application using the App directory:
- It has a standard
RootLayout
inapp/layout.tsx
. - It has a nested
Layout
in a route groupapp/(app)/layout.tsx
. This layout contains<nav />
. - It has two server-side rendered pages:
app/(app)/a/page.tsx
andapp/(app)/b/page.tsx
. - Each page calls
getCurrentTime()
(defined onapp/functions.ts
) and then display the render time.
I want each navigation to a page to cause a re-render and run getCurrentTime()
again, but I couldn’t make the pages not cache. I’ve tried adding both export const revalidate = 0
and export const dynamic = "force-dynamic"
(docs), but couldn’t make it work.
I’m sure it’s pretty basic, but I still couldn’t get the hang of it.
View on StackBlitz