Next.js · Middle · Question 40 of 75
What does connection() from next/server do?
- ✓Correct answer: Signals that rendering from here on must wait for an actual request
- 2Opens a database connection pool for the current request
- 3Checks that the user has an internet connection
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>.