Next.js Discord

Discord Forum

How to revalidatePath a specific nested dynamic route [category]/[subcategory]

Unanswered
Oriental posted this in #help-forum
Open in Discord
OrientalOP
I have two categories that I statically generate at build time. furniture/[subcategory] and interior/[subcategory]

I am trying to revalidate just a specific segment and all of its other paths.

For example, I want to revalidate the furniture category and all of its subcategories (but I want interior and its subcategories to remain unaffected). I've tried these two examples here but neither is working

I'm also thinking the second example is not what I want, as it means to revalidate layouts starting from /furniture/[subcategory], which would skip revalidating furniture (please correct me if I'm wrong)

revalidatePath('/furniture', 'layout');

revalidatePath('/furniture/[subcategory]', 'layout');


V0 says to do this, however, no example in the docs shows this way.

// This will revalidate the furniture category and all its subcategories
revalidatePath('/furniture/*');

0 Replies