Skip to content
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

Docs: Cookies function incorrectly documented as returning a Promise #73175

Closed
Keith-Web3 opened this issue Nov 25, 2024 · 3 comments
Closed
Labels
Documentation Related to Next.js' official documentation. locked

Comments

@Keith-Web3
Copy link

What is the documentation issue?

There is incorrect information about the cookies function imported from next/headers returning a promise. From using it, I found that it actually returned a ReadonlyRequestCookies type and doesn't need to be awaited as most part of the cookies docs suggest.

Is there any context that might help us understand?

The cookies function returns a ReadOnlyRequestCookies type and not a promise hence it doesn't need to be awaited as suggested by the docs.

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/api-reference/functions/cookies

@Keith-Web3 Keith-Web3 added the Documentation Related to Next.js' official documentation. label Nov 25, 2024
@DevFromSiberia
Copy link

In the section below - ‘good to know’ - it says the following:

  • Сookies is an asynchronous function that returns a promise. You must use async/await or React's use function to access cookies.
  • In version 14 and earlier, cookies was a synchronous function. To help with backwards compatability, you can still access it synchronously in Next.js 15, but this behavior will be deprecated in the future.

What version do you have?

@Keith-Web3
Copy link
Author

Oh! I see. Was on version 14, thanks for the clarification.

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Related to Next.js' official documentation. locked
Projects
None yet
Development

No branches or pull requests

2 participants