runtime (route segment config)
Selects the Node.js or Edge runtime for a route segment.
Syntax
export const runtime = 'nodejs' | 'edge' Returns
string — The execution runtime for the segment.
Examples
// Run this Route Handler on the Edge runtime
export const runtime = 'edge'
export async function GET() {
return Response.json({ region: process.env.VERCEL_REGION })
}
// Explicitly use the Node.js runtime (default)
export const runtime = 'nodejs'
export default async function Page() {
const fs = await import('node:fs/promises')
const data = await fs.readFile('./data.json', 'utf8')
return <pre>{data}</pre>
}
Notes
Default is `nodejs` (full Node APIs, larger cold start). `edge` uses
the lightweight Edge runtime: faster startup and global execution but
a limited Web-only API surface (no native Node modules). Choose
`edge` for tiny, latency-sensitive handlers. Exported from
`page.js`/`layout.js`/`route.js`.