Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update revalidatePath.mdx #54631

Merged
merged 4 commits into from Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 23 additions & 5 deletions docs/02-app/02-api-reference/04-functions/revalidatePath.mdx
Expand Up @@ -41,13 +41,22 @@ export default async function submit() {
### Route Handler

```ts filename="app/api/revalidate/route.ts" switcher
import { NextRequest, NextResponse } from 'next/server'
import { revalidatePath } from 'next/cache'
import { NextRequest, NextResponse } from 'next/server'

export async function GET(request: NextRequest) {
const path = request.nextUrl.searchParams.get('path')
revalidatePath(path)
return NextResponse.json({ revalidated: true, now: Date.now() })

if (path) {
revalidatePath(path)
return NextResponse.json({ revalidated: true, now: Date.now() })
}

return NextResponse.json({
revalidated: false,
now: Date.now(),
message: 'Missing path to revalidate',
})
}
```

Expand All @@ -57,7 +66,16 @@ import { revalidatePath } from 'next/cache'

export async function GET(request) {
const path = request.nextUrl.searchParams.get('path')
revalidatePath(path)
return NextResponse.json({ revalidated: true, now: Date.now() })

if (path) {
revalidatePath(path)
return NextResponse.json({ revalidated: true, now: Date.now() })
}

return NextResponse.json({
revalidated: false,
now: Date.now(),
message: 'Missing path to revalidate',
})
}
```