Next.js · Middle · Question 40 of 75

What does connection() from next/server do?

Explanation

It's needed when a component uses values that mustn't be computed during prerendering but doesn't access cookies() or headers(): for example, Math.random() or the current time. With Cache Components, such a component goes inside <Suspense>.

Further reading

Problem with a question

Next.js · Middle · question 40

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