mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This provides a way to refresh the client cache from within a server action. This is useful when you need to refresh the client UI / read your writes without needing to rely on `updateTag`. --------- Co-authored-by: JJ Kasper <[email protected]>
14 lines
320 B
TypeScript
14 lines
320 B
TypeScript
import { connection } from 'next/server'
|
|
import { unstable_cache, refresh } from 'next/cache'
|
|
|
|
const cachedFunction = unstable_cache(async () => {
|
|
refresh()
|
|
return 'data'
|
|
}, ['test-key'])
|
|
|
|
export default async function Page() {
|
|
await connection()
|
|
const data = await cachedFunction()
|
|
return <div>{data}</div>
|
|
}
|