File size: 1,036 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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>
    </>
  )
}