Next.js Discord

Discord Forum

revalidatePath('...','layout') in nested routes

Unanswered
Red-tailed Hawk posted this in #help-forum
Open in Discord
Red-tailed HawkOP
Salutations! We are working on a project where we need to dynamically revalidate multiple pages within a specific segment of our Next.js application. Specifically, we have a nested route structure like this: mainPath/[id]/subPath/[subPathId]. I want to revalidate all [subPathId] pages for a given id without having to revalidate each one individually.

Next Version: 14.0.1 React Version: 18.2.0

app/
└── mainPath/
└── [id]/
├── page.js
└── subPath/
└── [subPathId]/
└── page.js
Objective: Dynamically revalidate all [subPathId] pages under a specific id segment. Current Approach: Utilizing revalidatePath, but unclear on how to target all [subPathId] paths for a given id without individual revalidation calls.

0 Replies