connection()

Opts a component into dynamic rendering, waiting for an incoming request.

Since Next 15 Spec ↗

Syntax

import { connection } from 'next/server'; await connection()

Returns

Promise<void> — Resolves once a user request is connected.

Examples

import { connection } from 'next/server'

export default async function Page() {
  await connection()
  // Runs only at request time, never at build/prerender
  const rand = Math.random()
  return <p>Random: {rand}</p>
}
import { connection } from 'next/server'

async function Now() {
  await connection()
  return <time>{new Date().toISOString()}</time>
}

Notes

Replaces the old `unstable_noStore()` pattern for forcing dynamic rendering when you are not using `cookies()`/`headers()`. Use it before code that must not run during prerendering (random values, current time, uncached external calls). Server-only; Next 15.

See also