Skip to content

Commit 1b8ce8f

Browse files
authored
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: #49387 (comment)
1 parent 9697bcd commit 1b8ce8f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/02-app/02-api-reference/04-functions/revalidatePath.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ This will revalidate one specific URL on the next page visit.
3939
```ts
4040
import { revalidatePath } from 'next/cache'
4141
revalidatePath('/blog/[slug]', 'page')
42+
// or with route groups
43+
revalidatePath('/(main)/post/[slug]', 'page')
4244
```
4345

4446
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
4850
```ts
4951
import { revalidatePath } from 'next/cache'
5052
revalidatePath('/blog/[slug]', 'layout')
53+
// or with route groups
54+
revalidatePath('/(main)/post/[slug]', 'layout')
5155
```
5256

5357
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.

0 commit comments

Comments
 (0)