Download next.js/test/e2e/app-dir/actions/app/revalidate-2/page.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/actions/app/revalidate-2/page.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/e2e/app-dir/actions/app/revalidate-2/page.js
-
curl -L -o page.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/app-dir/actions/app/revalidate-2/page.js
1.04 kB
| import { unstable_expireTag } from 'next/cache' | |
| import { cookies } from 'next/headers' | |
| import Link from 'next/link' | |
| export default async function Page() { | |
| const randomCookie = (await cookies()).get('random') | |
| const data = await fetch( | |
| 'https://next-data-api-endpoint.vercel.app/api/random?page', | |
| { | |
| next: { revalidate: 3600, tags: ['thankyounext'] }, | |
| } | |
| ).then((res) => res.text()) | |
| return ( | |
| <> | |
| <h1 id="title">another route</h1> | |
| <Link href="/revalidate" id="back"> | |
| Back | |
| </Link> | |
| <p> | |
| {' '} | |
| revalidate (tags: thankyounext): <span id="thankyounext">{data}</span> | |
| </p> | |
| <form> | |
| <button | |
| id="revalidate-tag" | |
| formAction={async () => { | |
| 'use server' | |
| unstable_expireTag('thankyounext') | |
| }} | |
| > | |
| revalidate thankyounext | |
| </button> | |
| </form> | |
| <p> | |
| random cookie:{' '} | |
| <span id="random-cookie">{JSON.stringify(randomCookie)}</span> | |
| </p> | |
| </> | |
| ) | |
| } | |