eivindml
eivindml

Reputation: 2529

Next.js 14: Why won't revalidatePath() revalidate this page?

I have this website that displays events in a calendar and an event page for each event.

URLs and paths

These are my paths and URLs.

Revalidate function

This is the relevant part of my revalidate function. It works, I see that it's called correctly. I'm here just desperately trying every permutation to see if my syntax is wrong.

 .with({ _type: "event" }, (doc) => {
  console.log("/[lang]/arrangement");
  revalidatePath("/nb/kalender");
  revalidatePath("/nb/kalender/page");
  revalidatePath("/nb/kalender/page", "page");
  revalidatePath("/[lang]/kalender/page", "page");
  revalidatePath("/[lang]/kalender", "page");
  revalidatePath("/[lang]/kalender", "layout");
  revalidatePath("/nb/kalender", "layout");
  revalidatePath("/[lang]/kalender");
  revalidatePath(`/nb/arrangement/${doc.slug.current}`);
  revalidatePath(`/en/arrangement/${doc.slug.current}`);
  console.log("/[lang]/kalender");
  revalidatePath("/en/calendar", "page");
  console.log("/[lang]");
  revalidatePath("/nb", "page");
  revalidatePath("/en", "page");
  revalidatePath("/", "layout");
  return Response.json({ revalidated: true, now: Date.now() });
})

The problem

The issue here is that the url/path of the single event gets revalidated correctly (/nb/arrangement/en-skole-for-alle), but /nb/kalender won't be revalidated no matter what I try.

Locally (when building and then pnpm start), it correctly revalidates both pages, but when deployed to Vercel, it won't revalidate this one page.

What is the issue? Any tips on what I can try out?

Upvotes: 0

Views: 4137

Answers (2)

Anish Ali
Anish Ali

Reputation: 37

This issue exists when you try to run client component in server components without defining 'use client' in it

suppose you have -layout ( server component ) -page ( server component ) -page-component ( client component without defining 'use client')

and when you call 'page-component.tsx' in layout or page component it doesn't work well

if you didn't understand let me know

Upvotes: -1

eivindml
eivindml

Reputation: 2529

Finally figured it out.

My issue was actually a missing <Suspense> boundary around useSearchParams(), which made the "Entire page deopted into client-side rendering". Which then disabled the static page generation and revalidation for this route.

Very sneaky issue to figure ut.

Upvotes: 2

Related Questions