rembrembdocs

connection

Last updated April 23, 2026

The connection() function allows you to indicate rendering should wait for an incoming user request before continuing.

It's useful when a component doesn't use Request-time APIs, but you want it to be rendered at runtime and not prerendered at build time. This usually occurs when you access external information that you intentionally want to change the result of a render, such as Math.random() or new Date().

app/page.tsx

JavaScriptTypeScript

import { connection } from 'next/server'
 
export default async function Page() {
  await connection()
  // Everything below will be excluded from prerendering
  const rand = Math.random()
  return <span>{rand}</span>
}

Reference

Type

function connection(): Promise<void>

Parameters

Returns

Good to know

Version History

VersionChanges
v15.0.0connection stabilized.
v15.0.0-RCconnection introduced.

Was this helpful?