Unverified Commit 1b8ce8f6 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Add route groups example to revalidatePath doc (#55543)

Adds explicit examples for route groups as those may not be obvious from
existing examples.

x-ref:
https://github.com/vercel/next.js/issues/49387#issuecomment-1722575969
parent 9697bcd3
......@@ -39,6 +39,8 @@ This will revalidate one specific URL on the next page visit.
```ts
import { revalidatePath } from 'next/cache'
revalidatePath('/blog/[slug]', 'page')
// or with route groups
revalidatePath('/(main)/post/[slug]', 'page')
```
This will revalidate any URL that matches the provided `page` file on the next page visit. This will _not_ invalidate pages beneath the specific page. For example, `/blog/[slug]` won't invalidate `/blog/[slug]/[author]`.
......@@ -48,6 +50,8 @@ This will revalidate any URL that matches the provided `page` file on the next p
```ts
import { revalidatePath } from 'next/cache'
revalidatePath('/blog/[slug]', 'layout')
// or with route groups
revalidatePath('/(main)/post/[slug]', 'layout')
```
This will revalidate any URL that matches the provided `layout` file on the next page visit. This will cause pages beneath with the same layout to revalidate on the next visit. For example, in the above case, `/blog/[slug]/[another]` would also revalidate on the next visit.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment