mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
- rename `unstable_after` -> `after` - remove `experimental.after` flag (and warn if it's present) i separated the big find-and-replace into a separate commit so that it's easier to see what else changed apart from that. does not touch docs, that's in #73038
32 lines
800 B
JavaScript
32 lines
800 B
JavaScript
import { after } from 'next/server'
|
|
import { cookies } from 'next/headers'
|
|
|
|
export default async function Index() {
|
|
const cookieStore = await cookies()
|
|
after(async () => {
|
|
cookieStore.set('testCookie', 'after-render', { path: '/' })
|
|
})
|
|
|
|
const action = async () => {
|
|
'use server'
|
|
const cookieStore = await cookies()
|
|
cookieStore.set('testCookie', 'action', { path: '/' })
|
|
|
|
after(async () => {
|
|
cookieStore.set('testCookie', 'after-action', { path: '/' })
|
|
})
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<h1>Page with after() that tries to set cookies</h1>
|
|
<div id="cookie">
|
|
Cookie: {JSON.stringify(cookieStore.get('testCookie')?.value ?? null)}
|
|
</div>
|
|
<form action={action}>
|
|
<button type="submit">Submit</button>
|
|
</form>
|
|
</div>
|
|
)
|
|
}
|