Next.js · Middle · Question 20 of 75

How do you read a cookie in a Next.js 16 server component?

Explanation

cookies() and headers() are async: synchronous access was removed in Next.js 16. Using them makes rendering request-dependent. You can set cookies in Server Actions and Route Handlers, but not while rendering a server component.

Further reading

Problem with a question

Next.js · Middle · question 20

Test yourself

Take the Next.js · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz