docs: Cookies store access is async (#83987)

Noted through a feedback channel.
This commit is contained in:
Joseph
2025-09-23 15:31:35 +02:00
committed by GitHub
parent 521dcf55bf
commit 84b0e94586
+5 -3
View File
@@ -24,9 +24,10 @@ import { cookies } from 'next/headers'
async function getCookieData() {
return new Promise((resolve) =>
setTimeout(() => {
setTimeout(async () => {
// cookies will be called outside of the async context, causing a build-time error
resolve(cookies().getAll())
const cookieStore = await cookies()
resolve(cookieStore.getAll())
}, 1000)
)
}
@@ -50,7 +51,8 @@ export default async function Page() {
import { cookies } from 'next/headers'
async function getCookieData() {
const cookieData = cookies().getAll()
const cookieStore = await cookies()
const cookieData = cookieStore.getAll()
return new Promise((resolve) =>
setTimeout(() => {
resolve(cookieData)