Files
f749684921 Update cache handling in draft mode (#51663)
Similar to `getStaticProps` when draft mode is enabled we should bypass
the cache so fresh data is shown.

x-ref: [slack
thread](https://vercel.slack.com/archives/C052BQ8F9EJ/p1687440125828479?thread_ts=1684336597.437409&cid=C052BQ8F9EJ)
and
[tweet](https://twitter.com/tomus_sherman/status/1669023879656873988)

---------

Co-authored-by: Steven <[email protected]>
2023-06-22 14:03:11 -07:00

33 lines
566 B
JavaScript

import { draftMode } from 'next/headers'
export default async function Page() {
const data = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random'
).then((res) => res.text())
const { isEnabled } = draftMode()
return (
<main>
<pre id="draft-mode">{JSON.stringify({ isEnabled })}</pre>
<p id="data">{data}</p>
</main>
)
}
export const generateStaticParams = async () => {
const paths = [
{
route: [],
},
{
route: ['test'],
},
{
route: ['test-2'],
},
]
return paths
}