---
source: https://iinventedlight.com/library/notes/nextjs-connection.md
title: "Wait for a Next.js request with connection() before request-time work"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (Next.js docs); CC-BY-4.0 (React docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Next.js docs, connection; React docs, use. MIT; CC-BY-4.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: Next.js connection() and React use"
tags: [nextjs, connection, prerender, react, use]
client: Librarian
sources:
  - id: S1
    title: "connection"
    publisher: Next.js docs
    url: https://nextjs.org/docs/app/api-reference/functions/connection
    accessed: 2026-11-19
    license: "MIT"
  - id: S2
    title: "use"
    publisher: React docs
    url: https://react.dev/reference/react/use
    accessed: 2026-11-19
    license: "CC-BY-4.0"
---
# Wait for a Next.js request with connection() before request-time work
**Answer:** The `connection()` function in `next/server` allows you to indicate rendering should wait for an incoming user request before continuing. Awaiting it stops prerendering at that line. React's `use()` is a different wait: it reads a Promise or context during rendering.

## When to call connection()

It is useful when a component does not use Request-time APIs such as `cookies` or `headers`, yet still needs different output per request, for example `Math.random()` or `new Date()`. The example is `await connection()` in a page, then code that only runs at request time. Queries from synchronous database drivers can complete during prerendering. Call `connection()` before such a query if you are not already using a Request-time API.

## Waiting with use()

`use` lets you read a resource during rendering, such as a Promise or context. `connection()` waits for the incoming user request. Use `use()` when the component reads a Promise or context value.

| connection() | use() |
|---|---|
| connection() | Wait for an incoming user request |
| prerendering | Stops at await connection() |
| cookies and headers | Request-time APIs |
| use() | Reads a Promise or context during render |

## See also

- [nextjs-cookies-and-headers](https://iinventedlight.com/library/notes/nextjs-cookies-and-headers/)
- [nextjs-server-and-client-components](https://iinventedlight.com/library/notes/nextjs-server-and-client-components/)
- [nextjs-caching-use-cache](https://iinventedlight.com/library/notes/nextjs-caching-use-cache/)

## Claims

- id: C1
  claim: connection() indicates that rendering should wait for an incoming user request.
  source: S1
  evidence: "wait for an incoming user request"

- id: C2
  claim: Awaiting connection() stops prerendering at that point.
  source: S1
  evidence: "prerendering stops here"

- id: C3
  claim: React use() can read a Promise during rendering, which also waits before producing UI.
  source: S2
  evidence: "read a resource during rendering"

## Sources

- [S1] connection. Next.js docs. https://nextjs.org/docs/app/api-reference/functions/connection . License: MIT. Accessed 2026-11-19.

- [S2] use. React docs. https://react.dev/reference/react/use . License: CC-BY-4.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Next.js docs, connection; React docs, use. MIT; CC-BY-4.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
