Skip to content

Await cookies() Before Accessing Session Data #1859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

destocot
Copy link

@destocot destocot commented Mar 17, 2025

What does this PR do?

Updating the code to explicitly wrap await cookies() in parentheses to resolve the Next.js error:

cookies().get('my-custom-session') should be awaited before using its value.

This solved the current error provided:
cookies().get('my-custom-session'). cookies() should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis

Test Plan

Changed the code and refreshed my page.tsx component, no error being shown in logs after change.

Updateing the code to explicitly wrap await cookies() in parentheses to resolve the Next.js error:

cookies().get('my-custom-session') should be awaited before using its value.

This solved the current error provided:
`cookies().get('my-custom-session')`. `cookies()` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant