A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://rc.nextjs.org/docs/app/api-reference/functions/revalidateTag below:

Website Navigation


Functions: revalidateTag | Next.js

revalidateTag

revalidateTag allows you to purge cached data on-demand for a specific cache tag.

Good to know:

Parameters
revalidateTag(tag: string): void;

You can add tags to fetch as follows:

fetch(url, { next: { tags: [...] } });
Returns

revalidateTag does not return a value.

Examples Server Action
'use server'
 
import { revalidateTag } from 'next/cache'
 
export default async function submit() {
  await addPost()
  revalidateTag('posts')
}
Route Handler app/api/revalidate/route.ts
import type { NextRequest } from 'next/server'
import { revalidateTag } from 'next/cache'
 
export async function GET(request: NextRequest) {
  const tag = request.nextUrl.searchParams.get('tag')
  revalidateTag(tag)
  return Response.json({ revalidated: true, now: Date.now() })
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4