[{"id": "49a7b011671231e5", "url": "https://nextjs.org/docs", "page_title": "Next.js Docs", "page_type": "overview", "page_summary": "This page is the main documentation index for Next.js, providing an overview of what Next.js is, how to use the docs, the difference between App Router and Pages Router, prerequisites, accessibility…", "heading": "What is Next.js?", "content": "Page: Next.js Docs\nSection: What is Next.js?\n\nNext.js is a React framework for building full-stack web applications. You use React Components to build user interfaces, and Next.js for additional features and optimizations. It also automatically…", "code_blocks": [], "chunk_position": 0, "heading_path": "What is Next.js? > What is Next.js?", "breadcrumbs": "Next.js Docs > What is Next.js? > What is Next.js?"}, {"id": "c1cff99d047ba4f1", "url": "https://nextjs.org/docs", "page_title": "Next.js Docs", "page_type": "overview", "page_summary": "This page is the main documentation index for Next.js, providing an overview of what Next.js is, how to use the docs, the difference between App Router and Pages Router, prerequisites, accessibility…", "heading": "How to use the docs", "content": "Page: Next.js Docs\nSection: How to use the docs\n\nThe docs are organized into 3 sections:\n\n- Getting Started: Step-by-step tutorials to help you create a new application and learn the core Next.js features.\n- Guides: Tutorials on specific use cases,…", "code_blocks": [], "chunk_position": 0, "heading_path": "How to use the docs > How to use the docs", "breadcrumbs": "Next.js Docs > How to use the docs > How to use the docs"}, {"id": "db1a3cafb5485ac1", "url": "https://nextjs.org/docs", "page_title": "Next.js Docs", "page_type": "overview", "page_summary": "This page is the main documentation index for Next.js, providing an overview of what Next.js is, how to use the docs, the difference between App Router and Pages Router, prerequisites, accessibility…", "heading": "App Router and Pages Router", "content": "Page: Next.js Docs\nSection: App Router and Pages Router\n\nNext.js has two different routers:\n\n- App Router: The newer router that supports new React features like Server Components.\n- Pages Router: The original router, still supported and being…", "code_blocks": [], "chunk_position": 0, "heading_path": "App Router and Pages Router > App Router and Pages Router", "breadcrumbs": "Next.js Docs > App Router and Pages Router > App Router and Pages Router"}, {"id": "c281309403440bdc", "url": "https://nextjs.org/docs", "page_title": "Next.js Docs", "page_type": "overview", "page_summary": "This page is the main documentation index for Next.js, providing an overview of what Next.js is, how to use the docs, the difference between App Router and Pages Router, prerequisites, accessibility…", "heading": "React version handling", "content": "Page: Next.js Docs\nSection: React version handling\n\nThe App Router and Pages Router handle React versions differently:\n\n- App Router: Uses React canary releases built-in, which include all the stable React 19 changes, as well as newer features being…", "code_blocks": [], "chunk_position": 0, "heading_path": "React version handling > React version handling", "breadcrumbs": "Next.js Docs > React version handling > React version handling"}, {"id": "63373484bff266c6", "url": "https://nextjs.org/docs", "page_title": "Next.js Docs", "page_type": "overview", "page_summary": "This page is the main documentation index for Next.js, providing an overview of what Next.js is, how to use the docs, the difference between App Router and Pages Router, prerequisites, accessibility…", "heading": "Pre-requisite knowledge", "content": "Page: Next.js Docs\nSection: Pre-requisite knowledge\n\nOur documentation assumes some familiarity with web development. Before getting started, it'll help if you're comfortable with:\n\n- HTML\n- CSS\n- JavaScript\n- React\n\nIf you're new to React or need a…", "code_blocks": [], "chunk_position": 0, "heading_path": "Pre-requisite knowledge > Pre-requisite knowledge", "breadcrumbs": "Next.js Docs > Pre-requisite knowledge > Pre-requisite knowledge"}, {"id": "84cf626ad71d9311", "url": "https://nextjs.org/docs", "page_title": "Next.js Docs", "page_type": "overview", "page_summary": "This page is the main documentation index for Next.js, providing an overview of what Next.js is, how to use the docs, the difference between App Router and Pages Router, prerequisites, accessibility…", "heading": "Accessibility", "content": "Page: Next.js Docs\nSection: Accessibility\n\nFor the best experience when using a screen reader, we recommend using Firefox and NVDA, or Safari and VoiceOver.", "code_blocks": [], "chunk_position": 0, "heading_path": "Accessibility > Accessibility", "breadcrumbs": "Next.js Docs > Accessibility > Accessibility"}, {"id": "d81ecb471907b5ee", "url": "https://nextjs.org/docs", "page_title": "Next.js Docs", "page_type": "overview", "page_summary": "This page is the main documentation index for Next.js, providing an overview of what Next.js is, how to use the docs, the difference between App Router and Pages Router, prerequisites, accessibility…", "heading": "Join our Community", "content": "Page: Next.js Docs\nSection: Join our Community\n\nIf you have questions about anything related to Next.js, you're always welcome to ask our community on GitHub Discussions, Discord, X (Twitter), and Reddit.", "code_blocks": [], "chunk_position": 0, "heading_path": "Join our Community > Join our Community", "breadcrumbs": "Next.js Docs > Join our Community > Join our Community"}, {"id": "d0d5a5d432558735", "url": "https://nextjs.org/docs", "page_title": "Next.js Docs", "page_type": "overview", "page_summary": "This page is the main documentation index for Next.js, providing an overview of what Next.js is, how to use the docs, the difference between App Router and Pages Router, prerequisites, accessibility…", "heading": "Next Steps", "content": "Page: Next.js Docs\nSection: Next Steps\n\nCreate your first application and learn the core Next.js features.", "code_blocks": [], "chunk_position": 0, "heading_path": "Next Steps > Next Steps", "breadcrumbs": "Next.js Docs > Next Steps > Next Steps"}, {"id": "ebe9df97ca6b3493", "url": "https://nextjs.org/docs/app", "page_title": "App Router", "page_type": "overview", "page_summary": "Overview of the Next.js App Router, a file-system based router that leverages React's latest features such as Server Components, Suspense, and Server Functions.", "heading": "App Router", "content": "Page: App Router\nSection: App Router\n\nThe App Router is a file-system based router that uses React's latest features such as Server Components, Suspense, and Server Functions.", "code_blocks": [], "chunk_position": 1, "heading_path": "App Router > App Router", "breadcrumbs": "App Router > App Router > App Router"}, {"id": "8a5db630cecc0987", "url": "https://nextjs.org/docs/app", "page_title": "App Router", "page_type": "overview", "page_summary": "Overview of the Next.js App Router, a file-system based router that leverages React's latest features such as Server Components, Suspense, and Server Functions.", "heading": "Next Steps", "content": "Page: App Router\nSection: Next Steps\n\nLearn the fundamentals of building an App Router project, from installation to layouts, navigation, server and client components.\n\n- Installation: Learn how to create a new Next.js application with…", "code_blocks": [], "chunk_position": 1, "heading_path": "Next Steps > Next Steps", "breadcrumbs": "App Router > Next Steps > Next Steps"}, {"id": "1e243e78040f0979", "url": "https://nextjs.org/docs/app/api-reference", "page_title": "API Reference", "page_type": "overview", "page_summary": "Index page for Next.js App Router API references, listing categories such as Directives, Components, File-system conventions, Functions, Configuration, CLI, Adapters, Edge Runtime, and Turbopack.", "heading": "Directives", "content": "Page: API Reference\nSection: Directives\n\nDirectives are used to modify the behavior of your Next.js application.", "code_blocks": [], "chunk_position": 2, "heading_path": "Directives > Directives", "breadcrumbs": "API Reference > Directives > Directives"}, {"id": "f3364551f3f1b391", "url": "https://nextjs.org/docs/app/api-reference", "page_title": "API Reference", "page_type": "overview", "page_summary": "Index page for Next.js App Router API references, listing categories such as Directives, Components, File-system conventions, Functions, Configuration, CLI, Adapters, Edge Runtime, and Turbopack.", "heading": "File-system conventions", "content": "Page: API Reference\nSection: File-system conventions\n\nAPI Reference for Next.js file-system conventions.", "code_blocks": [], "chunk_position": 2, "heading_path": "File-system conventions > File-system conventions", "breadcrumbs": "API Reference > File-system conventions > File-system conventions"}, {"id": "2a2ee6bdcc5ddf9c", "url": "https://nextjs.org/docs/app/api-reference", "page_title": "API Reference", "page_type": "overview", "page_summary": "Index page for Next.js App Router API references, listing categories such as Directives, Components, File-system conventions, Functions, Configuration, CLI, Adapters, Edge Runtime, and Turbopack.", "heading": "CLI", "content": "Page: API Reference\nSection: CLI\n\nAPI Reference for the Next.js Command Line Interface (CLI) tools.", "code_blocks": [], "chunk_position": 2, "heading_path": "CLI > CLI", "breadcrumbs": "API Reference > CLI > CLI"}, {"id": "1e5c99dc3959af46", "url": "https://nextjs.org/docs/app/api-reference", "page_title": "API Reference", "page_type": "overview", "page_summary": "Index page for Next.js App Router API references, listing categories such as Directives, Components, File-system conventions, Functions, Configuration, CLI, Adapters, Edge Runtime, and Turbopack.", "heading": "Adapters", "content": "Page: API Reference\nSection: Adapters\n\nBuild deployment adapters for Next.js platforms and infrastructure.", "code_blocks": [], "chunk_position": 2, "heading_path": "Adapters > Adapters", "breadcrumbs": "API Reference > Adapters > Adapters"}, {"id": "9c88e40140f73918", "url": "https://nextjs.org/docs/app/api-reference", "page_title": "API Reference", "page_type": "overview", "page_summary": "Index page for Next.js App Router API references, listing categories such as Directives, Components, File-system conventions, Functions, Configuration, CLI, Adapters, Edge Runtime, and Turbopack.", "heading": "Turbopack", "content": "Page: API Reference\nSection: Turbopack\n\nTurbopack is an incremental bundler optimized for JavaScript and TypeScript, written in Rust, and built into Next.js.", "code_blocks": [], "chunk_position": 2, "heading_path": "Turbopack > Turbopack", "breadcrumbs": "API Reference > Turbopack > Turbopack"}, {"id": "ab4ce0d7a8015902", "url": "https://nextjs.org/docs/app/api-reference/adapters", "page_title": "Adapters", "page_type": "overview", "page_summary": "Overview of Next.js deployment adapter documentation, covering configuration, creation, API reference, testing, routing, PPR, runtime integration, entrypoints, output types, routing information, use…", "heading": "Adapters", "content": "Page: Adapters\nSection: Adapters\n\nUse this section to build and validate deployment adapters that integrate with the Next.js build and runtime model.", "code_blocks": [], "chunk_position": 3, "heading_path": "Adapters > Adapters", "breadcrumbs": "Adapters > Adapters > Adapters"}, {"id": "fbe1d539e3734824", "url": "https://nextjs.org/docs/app/api-reference/adapters", "page_title": "Adapters", "page_type": "overview", "page_summary": "Overview of Next.js deployment adapter documentation, covering configuration, creation, API reference, testing, routing, PPR, runtime integration, entrypoints, output types, routing information, use…", "heading": "Configuration", "content": "Page: Adapters\nSection: Configuration\n\nConfigure `adapterPath` or `NEXT_ADAPTER_PATH` to use a custom deployment adapter.", "code_blocks": [], "chunk_position": 3, "heading_path": "Configuration > Configuration", "breadcrumbs": "Adapters > Configuration > Configuration"}, {"id": "87631253c4d743a9", "url": "https://nextjs.org/docs/app/api-reference/adapters", "page_title": "Adapters", "page_type": "overview", "page_summary": "Overview of Next.js deployment adapter documentation, covering configuration, creation, API reference, testing, routing, PPR, runtime integration, entrypoints, output types, routing information, use…", "heading": "Creating an Adapter", "content": "Page: Adapters\nSection: Creating an Adapter\n\nCreate an adapter module that implements the `NextAdapter` interface.", "code_blocks": [], "chunk_position": 3, "heading_path": "Creating an Adapter > Creating an Adapter", "breadcrumbs": "Adapters > Creating an Adapter > Creating an Adapter"}, {"id": "802a50b65afb8297", "url": "https://nextjs.org/docs/app/api-reference/adapters", "page_title": "Adapters", "page_type": "overview", "page_summary": "Overview of Next.js deployment adapter documentation, covering configuration, creation, API reference, testing, routing, PPR, runtime integration, entrypoints, output types, routing information, use…", "heading": "API Reference", "content": "Page: Adapters\nSection: API Reference\n\nReference for `modifyConfig` and `onBuildComplete` in the `NextAdapter` interface.", "code_blocks": [], "chunk_position": 3, "heading_path": "API Reference > API Reference", "breadcrumbs": "Adapters > API Reference > API Reference"}, {"id": "e096e482d88084f9", "url": "https://nextjs.org/docs/app/api-reference/adapters", "page_title": "Adapters", "page_type": "overview", "page_summary": "Overview of Next.js deployment adapter documentation, covering configuration, creation, API reference, testing, routing, PPR, runtime integration, entrypoints, output types, routing information, use…", "heading": "Testing Adapters", "content": "Page: Adapters\nSection: Testing Adapters\n\nValidate adapters with the Next.js compatibility test harness and custom lifecycle scripts.", "code_blocks": [], "chunk_position": 3, "heading_path": "Testing Adapters > Testing Adapters", "breadcrumbs": "Adapters > Testing Adapters > Testing Adapters"}, {"id": "a8a22241e7fb99cc", "url": "https://nextjs.org/docs/app/api-reference/adapters", "page_title": "Adapters", "page_type": "overview", "page_summary": "Overview of Next.js deployment adapter documentation, covering configuration, creation, API reference, testing, routing, PPR, runtime integration, entrypoints, output types, routing information, use…", "heading": "Routing with @next/routing", "content": "Page: Adapters\nSection: Routing with @next/routing\n\nUse `@next/routing` to apply Next.js route matching behavior in adapters.", "code_blocks": [], "chunk_position": 3, "heading_path": "Routing with @next/routing > Routing with @next/routing", "breadcrumbs": "Adapters > Routing with @next/routing > Routing with @next/routing"}, {"id": "8d6adfab7675d75d", "url": "https://nextjs.org/docs/app/api-reference/adapters", "page_title": "Adapters", "page_type": "overview", "page_summary": "Overview of Next.js deployment adapter documentation, covering configuration, creation, API reference, testing, routing, PPR, runtime integration, entrypoints, output types, routing information, use…", "heading": "Implementing PPR in an Adapter", "content": "Page: Adapters\nSection: Implementing PPR in an Adapter\n\nImplement Partial Prerendering support in an adapter using fallback output and cache hooks.", "code_blocks": [], "chunk_position": 3, "heading_path": "Implementing PPR in an Adapter > Implementing PPR in an Adapter", "breadcrumbs": "Adapters > Implementing PPR in an Adapter > Implementing PPR in an Adapter"}, {"id": "349731e475e6e96f", "url": "https://nextjs.org/docs/app/api-reference/adapters", "page_title": "Adapters", "page_type": "overview", "page_summary": "Overview of Next.js deployment adapter documentation, covering configuration, creation, API reference, testing, routing, PPR, runtime integration, entrypoints, output types, routing information, use…", "heading": "Runtime Integration", "content": "Page: Adapters\nSection: Runtime Integration\n\nUnderstand how build-time adapters and runtime cache interfaces work together.", "code_blocks": [], "chunk_position": 3, "heading_path": "Runtime Integration > Runtime Integration", "breadcrumbs": "Adapters > Runtime Integration > Runtime Integration"}, {"id": "33b4091494635aac", "url": "https://nextjs.org/docs/app/api-reference/adapters", "page_title": "Adapters", "page_type": "overview", "page_summary": "Overview of Next.js deployment adapter documentation, covering configuration, creation, API reference, testing, routing, PPR, runtime integration, entrypoints, output types, routing information, use…", "heading": "Invoking Entrypoints", "content": "Page: Adapters\nSection: Invoking Entrypoints\n\nInvoke Node.js and Edge build entrypoints with adapter runtime context.", "code_blocks": [], "chunk_position": 3, "heading_path": "Invoking Entrypoints > Invoking Entrypoints", "breadcrumbs": "Adapters > Invoking Entrypoints > Invoking Entrypoints"}, {"id": "6946585e872c9618", "url": "https://nextjs.org/docs/app/api-reference/adapters", "page_title": "Adapters", "page_type": "overview", "page_summary": "Overview of Next.js deployment adapter documentation, covering configuration, creation, API reference, testing, routing, PPR, runtime integration, entrypoints, output types, routing information, use…", "heading": "Output Types", "content": "Page: Adapters\nSection: Output Types\n\nReference for all build output types exposed to adapters.", "code_blocks": [], "chunk_position": 3, "heading_path": "Output Types > Output Types", "breadcrumbs": "Adapters > Output Types > Output Types"}, {"id": "00af66b262bd8af4", "url": "https://nextjs.org/docs/app/api-reference/adapters", "page_title": "Adapters", "page_type": "overview", "page_summary": "Overview of Next.js deployment adapter documentation, covering configuration, creation, API reference, testing, routing, PPR, runtime integration, entrypoints, output types, routing information, use…", "heading": "Routing Information", "content": "Page: Adapters\nSection: Routing Information\n\nReference for routing phases and route fields exposed in `onBuildComplete`.", "code_blocks": [], "chunk_position": 3, "heading_path": "Routing Information > Routing Information", "breadcrumbs": "Adapters > Routing Information > Routing Information"}, {"id": "23883c94e87c4b67", "url": "https://nextjs.org/docs/app/api-reference/adapters", "page_title": "Adapters", "page_type": "overview", "page_summary": "Overview of Next.js deployment adapter documentation, covering configuration, creation, API reference, testing, routing, PPR, runtime integration, entrypoints, output types, routing information, use…", "heading": "Use Cases", "content": "Page: Adapters\nSection: Use Cases\n\nCommon patterns and examples for deployment adapter implementations.", "code_blocks": [], "chunk_position": 3, "heading_path": "Use Cases > Use Cases", "breadcrumbs": "Adapters > Use Cases > Use Cases"}, {"id": "ccd6a7012033b5d0", "url": "https://nextjs.org/docs/app/api-reference/adapters/api-reference", "page_title": "API Reference", "page_type": "api", "page_summary": "This page describes the Next.js adapter API, including functions to modify configuration and handle build completion.", "heading": "`async modifyConfig(config, context)`", "content": "Page: API Reference\nSection: `async modifyConfig(config, context)`\n\nCalled for any CLI command that loads the `next.config.js` file to allow modification of the configuration.\n\n**Parameters:**\n\n- `config`: The complete Next.js configuration object\n- `context.phase`:…", "code_blocks": [], "chunk_position": 4, "heading_path": "`async modifyConfig(config, context)` > `async modifyConfig(config, context)`", "breadcrumbs": "API Reference > `async modifyConfig(config, context)` > `async modifyConfig(config, context)`"}, {"id": "ef56d4d12b7be83d", "url": "https://nextjs.org/docs/app/api-reference/adapters/api-reference", "page_title": "API Reference", "page_type": "api", "page_summary": "This page describes the Next.js adapter API, including functions to modify configuration and handle build completion.", "heading": "`async onBuildComplete(context)`", "content": "Page: API Reference\nSection: `async onBuildComplete(context)`\n\nCalled after the build process completes with detailed information about routes and outputs.\n\n**Parameters:**\n\n- `context.routing`: Object containing Next.js routing phases and metadata \n-…", "code_blocks": [], "chunk_position": 4, "heading_path": "`async onBuildComplete(context)` > `async onBuildComplete(context)`", "breadcrumbs": "API Reference > `async onBuildComplete(context)` > `async onBuildComplete(context)`"}, {"id": "0b75438d8a28d34d", "url": "https://nextjs.org/docs/app/api-reference/adapters/configuration", "page_title": "Configuration", "page_type": "api", "page_summary": "This page describes how to configure Next.js adapters by specifying the adapter module path via `adapterPath` in `next.config.js` or the `NEXT_ADAPTER_PATH` environment variable.", "heading": "Configuration", "content": "Page: Configuration\nSection: Configuration\n\nTo use an adapter, specify the path to your adapter module in `adapterPath`:\n\nAlternatively `NEXT_ADAPTER_PATH` can be set to enable zero-config usage in deployment platforms.", "code_blocks": [{"language": "js", "code": "/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  adapterPath: require.resolve('./my-adapter.js'),\n}\n \nmodule.exports = nextConfig", "filename": "next.config.js"}], "chunk_position": 5, "heading_path": "Configuration > Configuration", "breadcrumbs": "Configuration > Configuration > Configuration"}, {"id": "1cc09ee7efea8e7d", "url": "https://nextjs.org/docs/app/api-reference/adapters/creating-an-adapter", "page_title": "Creating an Adapter", "page_type": "guide", "page_summary": "This page explains how to create a custom adapter for Next.js by implementing the NextAdapter interface, including the interface definition and a minimal example.", "heading": "Creating an Adapter", "content": "Page: Creating an Adapter\nSection: Creating an Adapter\n\nAn adapter is a module that exports an object implementing the `NextAdapter` interface.\n\nThe interface can be imported from the `next` package:\n\nThe interface is defined as follows:", "code_blocks": [{"language": "typescript", "code": "import type { NextAdapter } from 'next'", "filename": ""}, {"language": "typescript", "code": "type Route = {\n  source?: string\n  sourceRegex: string\n  destination?: string\n  headers?: Record<string, string>\n  has?: RouteHas[]\n  missing?: RouteHas[]\n  status?: number\n  priority?: boolean\n}…", "filename": ""}], "chunk_position": 6, "heading_path": "Creating an Adapter > Creating an Adapter", "breadcrumbs": "Creating an Adapter > Creating an Adapter > Creating an Adapter"}, {"id": "94f1963d787e81fc", "url": "https://nextjs.org/docs/app/api-reference/adapters/immutable-static-assets", "page_title": "Adapters: Supporting Immutable Static Assets | Next.js", "page_type": "reference", "page_summary": "Explains how Next.js adapters can support immutable static assets, including the `supportsImmutableAssets` config flag, the shared-namespace runtime behavior of immutable assets, content-hash…", "heading": "Supporting Immutable Static Assets", "content": "Page: Adapters: Supporting Immutable Static Assets | Next.js\nSection: Supporting Immutable Static Assets\n\nSee [`config.supportsImmutableAssets`](/docs/app/api-reference/config/next-config-js/supportsImmutableAssets) for end-user-facing information about this feature.\n\nWhen…", "code_blocks": [], "chunk_position": 7, "heading_path": "Supporting Immutable Static Assets > Supporting Immutable Static Assets", "breadcrumbs": "Adapters: Supporting Immutable Static Assets | Next.js > Supporting Immutable Static Assets > Supporting Immutable Static Assets"}, {"id": "a824a0d7709cd033", "url": "https://nextjs.org/docs/app/api-reference/adapters/immutable-static-assets", "page_title": "Adapters: Supporting Immutable Static Assets | Next.js", "page_type": "reference", "page_summary": "Explains how Next.js adapters can support immutable static assets, including the `supportsImmutableAssets` config flag, the shared-namespace runtime behavior of immutable assets, content-hash…", "heading": "Adapter Implementation", "content": "Page: Adapters: Supporting Immutable Static Assets | Next.js\nSection: Adapter Implementation\n\nYou need to:\n\n- In the `modifyConfig`, set the `config.supportsImmutableAssets` property to `true` (if it's not already set to `false` by the user) to signal that you support deploying immutable…", "code_blocks": [{"language": "javascript", "code": "/** @type {import('next').NextAdapter} */\nconst adapter = {\n  name: 'my-custom-adapter',\n \n  async modifyConfig(config, { phase }) {\n    if (phase === 'phase-production-build') {…", "filename": "my-adapter.js"}], "chunk_position": 7, "heading_path": "Adapter Implementation > Adapter Implementation", "breadcrumbs": "Adapters: Supporting Immutable Static Assets | Next.js > Adapter Implementation > Adapter Implementation"}, {"id": "50e5cad42453595c", "url": "https://nextjs.org/docs/app/api-reference/adapters/implementing-ppr-in-an-adapter", "page_title": "Implementing PPR in an Adapter", "page_type": "guide", "page_summary": "This page explains how to implement Partial Prerendering (PPR) in a Next.js adapter, covering build-time seeding of fallback shells and postponed state, runtime streaming of cached shells with…", "heading": "Overview", "content": "Page: Implementing PPR in an Adapter\nSection: Overview\n\nFor partially prerendered app routes, `onBuildComplete` gives you the data needed to seed and resume PPR:\n\n- `outputs.prerenders[].fallback.filePath`: path to the generated fallback shell (for…", "code_blocks": [], "chunk_position": 8, "heading_path": "Overview > Overview", "breadcrumbs": "Implementing PPR in an Adapter > Overview > Overview"}, {"id": "87e8bd59499d7d6d", "url": "https://nextjs.org/docs/app/api-reference/adapters/implementing-ppr-in-an-adapter", "page_title": "Implementing PPR in an Adapter", "page_type": "guide", "page_summary": "This page explains how to implement Partial Prerendering (PPR) in a Next.js adapter, covering build-time seeding of fallback shells and postponed state, runtime streaming of cached shells with…", "heading": "1. Seed shell + postponed state at build time", "content": "Page: Implementing PPR in an Adapter\nSection: 1. Seed shell + postponed state at build time\n\n```ts\nimport { readFile } from 'node:fs/promises'\n \nasync function seedPprEntries(outputs: AdapterOutputs) {\n  for (const prerender of outputs.prerenders) {\n    const fallback = prerender.fallback\n    if…\n```", "code_blocks": [{"language": "ts", "code": "import { readFile } from 'node:fs/promises'\n \nasync function seedPprEntries(outputs: AdapterOutputs) {\n  for (const prerender of outputs.prerenders) {\n    const fallback = prerender.fallback\n    if…", "filename": "my-adapter.ts"}], "chunk_position": 8, "heading_path": "1. Seed shell + postponed state at build time > 1. Seed shell + postponed state at build time", "breadcrumbs": "Implementing PPR in an Adapter > 1. Seed shell + postponed state at build time > 1. Seed shell + postponed state at build time"}, {"id": "bffa069a55350e33", "url": "https://nextjs.org/docs/app/api-reference/adapters/implementing-ppr-in-an-adapter", "page_title": "Implementing PPR in an Adapter", "page_type": "guide", "page_summary": "This page explains how to implement Partial Prerendering (PPR) in a Next.js adapter, covering build-time seeding of fallback shells and postponed state, runtime streaming of cached shells with…", "heading": "2. Runtime flow: serve cached shell and resume in background", "content": "Page: Implementing PPR in an Adapter\nSection: 2. Runtime flow: serve cached shell and resume in background\n\nAt request time, you can stream a single response that is the concatenation of:\n\n- cached HTML shell stream\n- resumed render stream (generated after invoking `handler` with postponed state)", "code_blocks": [{"language": "text", "code": "Client\n  | GET /ppr-route\n  v\nAdapter Router\n  |\n  |-- read cached shell + postponedState ---> Platform Cache\n  |<------------- cache hit -----------------|\n  |\n  |-- create responseStream =…", "filename": ""}], "chunk_position": 8, "heading_path": "2. Runtime flow: serve cached shell and resume in background > 2. Runtime flow: serve cached shell and resume in background", "breadcrumbs": "Implementing PPR in an Adapter > 2. Runtime flow: serve cached shell and resume in background > 2. Runtime flow: serve cached shell and resume in background"}, {"id": "e14a82faf291d7fa", "url": "https://nextjs.org/docs/app/api-reference/adapters/implementing-ppr-in-an-adapter", "page_title": "Implementing PPR in an Adapter", "page_type": "guide", "page_summary": "This page explains how to implement Partial Prerendering (PPR) in a Next.js adapter, covering build-time seeding of fallback shells and postponed state, runtime streaming of cached shells with…", "heading": "3. Update cache with `requestMeta.onCacheEntryV2`", "content": "Page: Implementing PPR in an Adapter\nSection: 3. Update cache with `requestMeta.onCacheEntryV2`\n\n`requestMeta.onCacheEntryV2` is called when a response cache entry is looked up or generated. Use it to persist updated shell/postponed data.\n\n- `requestMeta.onCacheEntry` still works, but is…", "code_blocks": [{"language": "ts", "code": "await handler(req, res, {\n  waitUntil,\n  requestMeta: {\n    postponed: cachedPprEntry?.postponedState,\n    onCacheEntryV2: async (cacheEntry, meta) => {\n      if (cacheEntry.value?.kind ===…", "filename": "my-adapter.ts"}, {"language": "text", "code": "Entrypoint (handler)\n  | onCacheEntryV2(cacheEntry, { url })\n  v\nrequestMeta.onCacheEntryV2 callback\n  |\n  |-- if APP_PAGE ---> persist html + postponedState + headers ---> Platform Cache\n  |\n  '--…", "filename": ""}], "chunk_position": 8, "heading_path": "3. Update cache with `requestMeta.onCacheEntryV2` > 3. Update cache with `requestMeta.onCacheEntryV2`", "breadcrumbs": "Implementing PPR in an Adapter > 3. Update cache with `requestMeta.onCacheEntryV2` > 3. Update cache with `requestMeta.onCacheEntryV2`"}, {"id": "b7acaec6f16ccac2", "url": "https://nextjs.org/docs/app/api-reference/adapters/invoking-entrypoints", "page_title": "Adapters: Invoking Entrypoints | Next.js", "page_type": "reference", "page_summary": "This page describes how build output entrypoints use a `handler(..., ctx)` interface for Node.js and Edge runtimes, including how adapters can invoke entrypoints directly and use `requestMeta`…", "heading": "Invoking Entrypoints", "content": "Page: Adapters: Invoking Entrypoints | Next.js\nSection: Invoking Entrypoints\n\nBuild output entrypoints use a `handler(..., ctx)` interface, with runtime-specific request/response types.", "code_blocks": [], "chunk_position": 9, "heading_path": "Invoking Entrypoints > Invoking Entrypoints", "breadcrumbs": "Adapters: Invoking Entrypoints | Next.js > Invoking Entrypoints > Invoking Entrypoints"}, {"id": "c2a15b77271fbfb9", "url": "https://nextjs.org/docs/app/api-reference/adapters/invoking-entrypoints", "page_title": "Adapters: Invoking Entrypoints | Next.js", "page_type": "reference", "page_summary": "This page describes how build output entrypoints use a `handler(..., ctx)` interface for Node.js and Edge runtimes, including how adapters can invoke entrypoints directly and use `requestMeta`…", "heading": "Node.js runtime (`runtime: 'nodejs'`)", "content": "Page: Adapters: Invoking Entrypoints | Next.js\nSection: Node.js runtime (`runtime: 'nodejs'`)\n\nNode.js entrypoints use the following interface:\n\nWhen invoking Node.js entrypoints directly, adapters can pass helpers directly on `requestMeta` instead of relying on internals. Some of the…", "code_blocks": [{"language": "typescript", "code": "handler(\n  req: IncomingMessage,\n  res: ServerResponse,\n  ctx: {\n    waitUntil?: (promise: Promise<void>) => void\n    requestMeta?: RequestMeta\n  }\n): Promise<void>", "filename": ""}, {"language": "javascript", "code": "await handler(req, res, {\n  requestMeta: {\n    // Relative path from process.cwd() to the Next.js project directory.\n    relativeProjectDir: '.',\n    // Optional hostname used by route handlers when…", "filename": ""}], "chunk_position": 9, "heading_path": "Node.js runtime (`runtime: 'nodejs'`) > Node.js runtime (`runtime: 'nodejs'`)", "breadcrumbs": "Adapters: Invoking Entrypoints | Next.js > Node.js runtime (`runtime: 'nodejs'`) > Node.js runtime (`runtime: 'nodejs'`)"}, {"id": "e143f80116b7aa13", "url": "https://nextjs.org/docs/app/api-reference/adapters/invoking-entrypoints", "page_title": "Adapters: Invoking Entrypoints | Next.js", "page_type": "reference", "page_summary": "This page describes how build output entrypoints use a `handler(..., ctx)` interface for Node.js and Edge runtimes, including how adapters can invoke entrypoints directly and use `requestMeta`…", "heading": "Edge runtime (`runtime: 'edge'`) (deprecated)", "content": "Page: Adapters: Invoking Entrypoints | Next.js\nSection: Edge runtime (`runtime: 'edge'`) (deprecated)\n\n> The Edge Runtime is [deprecated](/docs/messages/edge-runtime-deprecated). New routes should use the Node.js runtime.\n\nEdge entrypoints use the following interface:\n\nThe shape is aligned around…", "code_blocks": [{"language": "typescript", "code": "handler(\n  request: Request,\n  ctx: {\n    waitUntil?: (prom: Promise<void>) => void\n    signal?: AbortSignal\n    requestMeta?: RequestMeta\n  }\n): Promise<Response>", "filename": ""}, {"language": "typescript", "code": "{\n  modulePath: string // Absolute path to the module registered in the edge runtime\n  entryKey: string // Canonical key used by the edge entry registry\n  handlerExport: string // Export name to…", "filename": ""}, {"language": "javascript", "code": "const entry = await globalThis._ENTRIES[output.edgeRuntime.entryKey]\nconst handler = entry[output.edgeRuntime.handlerExport]\nawait handler(request, ctx)", "filename": ""}], "chunk_position": 9, "heading_path": "Edge runtime (`runtime: 'edge'`) (deprecated) > Edge runtime (`runtime: 'edge'`) (deprecated)", "breadcrumbs": "Adapters: Invoking Entrypoints | Next.js > Edge runtime (`runtime: 'edge'`) (deprecated) > Edge runtime (`runtime: 'edge'`) (deprecated)"}, {"id": "54e2ad60ebdc198a", "url": "https://nextjs.org/docs/app/api-reference/adapters/output-types", "page_title": "Adapters: Output Types", "page_type": "api", "page_summary": "Describes the `outputs` object structure exposed to Next.js adapters, including arrays for pages, API routes, app pages, app routes, prerenders, static files, and middleware, with TypeScript type…", "heading": "Output Types", "content": "Page: Adapters: Output Types\nSection: Output Types\n\nThe `outputs` object contains arrays of build output types:\n\n- `outputs.pages`: React pages from the `pages/` directory\n- `outputs.pagesApi`: API routes from `pages/api/`\n- `outputs.appPages`: React…", "code_blocks": [], "chunk_position": 10, "heading_path": "Output Types > Output Types", "breadcrumbs": "Adapters: Output Types > Output Types > Output Types"}, {"id": "262c8dd3030a6b2f", "url": "https://nextjs.org/docs/app/api-reference/adapters/output-types", "page_title": "Adapters: Output Types", "page_type": "api", "page_summary": "Describes the `outputs` object structure exposed to Next.js adapters, including arrays for pages, API routes, app pages, app routes, prerenders, static files, and middleware, with TypeScript type…", "heading": "App Routes (`outputs.appRoutes`)", "content": "Page: Adapters: Output Types\nSection: App Routes (`outputs.appRoutes`)\n\nAPI and metadata routes from the `app/` directory:", "code_blocks": [{"language": "typescript", "code": "{\n  type: 'APP_ROUTE'\n  id: string           // Route identifier\n  filePath: string     // Path to the built file\n  pathname: string     // URL pathname\n  sourcePage: string   // Original relative…", "filename": ""}], "chunk_position": 10, "heading_path": "App Routes (`outputs.appRoutes`) > App Routes (`outputs.appRoutes`)", "breadcrumbs": "Adapters: Output Types > App Routes (`outputs.appRoutes`) > App Routes (`outputs.appRoutes`)"}, {"id": "ef4a942ee43f5471", "url": "https://nextjs.org/docs/app/api-reference/adapters/output-types", "page_title": "Adapters: Output Types", "page_type": "api", "page_summary": "Describes the `outputs` object structure exposed to Next.js adapters, including arrays for pages, API routes, app pages, app routes, prerenders, static files, and middleware, with TypeScript type…", "heading": "Prerender classification", "content": "Page: Adapters: Output Types\nSection: Prerender classification\n\n`routeType`, `response`, and `compute` are emitted together on the primary response in a prerender group. Related RSC, data, and segment outputs omit these fields. Pages Router templates with…", "code_blocks": [], "chunk_position": 10, "heading_path": "Prerender classification > Prerender classification", "breadcrumbs": "Adapters: Output Types > Prerender classification > Prerender classification"}, {"id": "89de3a99004fd55a", "url": "https://nextjs.org/docs/app/api-reference/adapters/output-types", "page_title": "Adapters: Output Types", "page_type": "api", "page_summary": "Describes the `outputs` object structure exposed to Next.js adapters, including arrays for pages, API routes, app pages, app routes, prerenders, static files, and middleware, with TypeScript type…", "heading": "Static Files (`outputs.staticFiles`)", "content": "Page: Adapters: Output Types\nSection: Static Files (`outputs.staticFiles`)\n\nStatic assets and auto-statically optimized pages:\n\nSee [Supporting immutable static assets](/docs/app/api-reference/adapters/immutable-static-assets) for more information about `immutableHash`.", "code_blocks": [{"language": "typescript", "code": "{\n  type: 'STATIC_FILE'\n  id: string // Unique identifier for this static file output\n  filePath: string // Absolute filesystem path to the built file\n  pathname: string // The routable URL pathname…", "filename": ""}], "chunk_position": 10, "heading_path": "Static Files (`outputs.staticFiles`) > Static Files (`outputs.staticFiles`)", "breadcrumbs": "Adapters: Output Types > Static Files (`outputs.staticFiles`) > Static Files (`outputs.staticFiles`)"}, {"id": "8e918fd93aa14b69", "url": "https://nextjs.org/docs/app/api-reference/adapters/output-types", "page_title": "Adapters: Output Types", "page_type": "api", "page_summary": "Describes the `outputs` object structure exposed to Next.js adapters, including arrays for pages, API routes, app pages, app routes, prerenders, static files, and middleware, with TypeScript type…", "heading": "Middleware (`outputs.middleware`)", "content": "Page: Adapters: Output Types\nSection: Middleware (`outputs.middleware`)\n\n`middleware.ts` (`.js`/`.ts`) or `proxy.ts` (`.js`/`.ts`) function (if present):", "code_blocks": [{"language": "typescript", "code": "{\n  type: 'MIDDLEWARE'\n  id: string           // Route identifier\n  filePath: string     // Path to the built file\n  pathname: string      // Always '/_middleware'\n  sourcePage: string    // Always…", "filename": ""}], "chunk_position": 10, "heading_path": "Middleware (`outputs.middleware`) > Middleware (`outputs.middleware`)", "breadcrumbs": "Adapters: Output Types > Middleware (`outputs.middleware`) > Middleware (`outputs.middleware`)"}, {"id": "777171ccf75c1789", "url": "https://nextjs.org/docs/app/api-reference/adapters/routing-information", "page_title": "Adapters: Routing Information", "page_type": "api", "page_summary": "Describes the `routing` object available in `onBuildComplete`, including the route phases and common fields that make up deployment-ready routing information.", "heading": "Routing Information", "content": "Page: Adapters: Routing Information\nSection: Routing Information\n\nThe `routing` object in `onBuildComplete` provides complete routing information with processed patterns ready for deployment:", "code_blocks": [], "chunk_position": 11, "heading_path": "Routing Information > Routing Information", "breadcrumbs": "Adapters: Routing Information > Routing Information > Routing Information"}, {"id": "4172f842573e25d0", "url": "https://nextjs.org/docs/app/api-reference/adapters/routing-information", "page_title": "Adapters: Routing Information", "page_type": "api", "page_summary": "Describes the `routing` object available in `onBuildComplete`, including the route phases and common fields that make up deployment-ready routing information.", "heading": "routing.beforeMiddleware", "content": "Page: Adapters: Routing Information\nSection: routing.beforeMiddleware\n\nRoutes applied before middleware execution. These include generated header and redirect behavior.", "code_blocks": [], "chunk_position": 11, "heading_path": "routing.beforeMiddleware > routing.beforeMiddleware", "breadcrumbs": "Adapters: Routing Information > routing.beforeMiddleware > routing.beforeMiddleware"}, {"id": "132bc4fb141dcf56", "url": "https://nextjs.org/docs/app/api-reference/adapters/routing-information", "page_title": "Adapters: Routing Information", "page_type": "api", "page_summary": "Describes the `routing` object available in `onBuildComplete`, including the route phases and common fields that make up deployment-ready routing information.", "heading": "routing.beforeFiles", "content": "Page: Adapters: Routing Information\nSection: routing.beforeFiles\n\nRewrite routes checked before filesystem route matching.", "code_blocks": [], "chunk_position": 11, "heading_path": "routing.beforeFiles > routing.beforeFiles", "breadcrumbs": "Adapters: Routing Information > routing.beforeFiles > routing.beforeFiles"}, {"id": "5ea99c9da9401c45", "url": "https://nextjs.org/docs/app/api-reference/adapters/routing-information", "page_title": "Adapters: Routing Information", "page_type": "api", "page_summary": "Describes the `routing` object available in `onBuildComplete`, including the route phases and common fields that make up deployment-ready routing information.", "heading": "routing.afterFiles", "content": "Page: Adapters: Routing Information\nSection: routing.afterFiles\n\nRewrite routes checked after filesystem route matching.", "code_blocks": [], "chunk_position": 11, "heading_path": "routing.afterFiles > routing.afterFiles", "breadcrumbs": "Adapters: Routing Information > routing.afterFiles > routing.afterFiles"}, {"id": "b6c6fc45dc855eda", "url": "https://nextjs.org/docs/app/api-reference/adapters/routing-information", "page_title": "Adapters: Routing Information", "page_type": "api", "page_summary": "Describes the `routing` object available in `onBuildComplete`, including the route phases and common fields that make up deployment-ready routing information.", "heading": "routing.dynamicRoutes", "content": "Page: Adapters: Routing Information\nSection: routing.dynamicRoutes\n\nDynamic matchers generated from route segments such as `[slug]` and catch-all routes.", "code_blocks": [], "chunk_position": 11, "heading_path": "routing.dynamicRoutes > routing.dynamicRoutes", "breadcrumbs": "Adapters: Routing Information > routing.dynamicRoutes > routing.dynamicRoutes"}, {"id": "dd7f10874a88847c", "url": "https://nextjs.org/docs/app/api-reference/adapters/routing-information", "page_title": "Adapters: Routing Information", "page_type": "api", "page_summary": "Describes the `routing` object available in `onBuildComplete`, including the route phases and common fields that make up deployment-ready routing information.", "heading": "routing.onMatch", "content": "Page: Adapters: Routing Information\nSection: routing.onMatch\n\nRoutes that apply after a successful match, such as immutable cache headers for hashed static assets.", "code_blocks": [], "chunk_position": 11, "heading_path": "routing.onMatch > routing.onMatch", "breadcrumbs": "Adapters: Routing Information > routing.onMatch > routing.onMatch"}, {"id": "c8dc2f6c89be20f1", "url": "https://nextjs.org/docs/app/api-reference/adapters/routing-information", "page_title": "Adapters: Routing Information", "page_type": "api", "page_summary": "Describes the `routing` object available in `onBuildComplete`, including the route phases and common fields that make up deployment-ready routing information.", "heading": "routing.fallback", "content": "Page: Adapters: Routing Information\nSection: routing.fallback\n\nFinal rewrite routes checked when earlier phases did not produce a match.", "code_blocks": [], "chunk_position": 11, "heading_path": "routing.fallback > routing.fallback", "breadcrumbs": "Adapters: Routing Information > routing.fallback > routing.fallback"}, {"id": "662db1af7a134336", "url": "https://nextjs.org/docs/app/api-reference/adapters/routing-information", "page_title": "Adapters: Routing Information", "page_type": "api", "page_summary": "Describes the `routing` object available in `onBuildComplete`, including the route phases and common fields that make up deployment-ready routing information.", "heading": "Common Route Fields", "content": "Page: Adapters: Routing Information\nSection: Common Route Fields\n\nEach route entry can include:\n\n- `source`: Original route pattern (optional for generated internal rules)\n- `sourceRegex`: Compiled regex for matching requests\n- `destination`: Internal destination…", "code_blocks": [], "chunk_position": 11, "heading_path": "Common Route Fields > Common Route Fields", "breadcrumbs": "Adapters: Routing Information > Common Route Fields > Common Route Fields"}, {"id": "5b15c89664d946b2", "url": "https://nextjs.org/docs/app/api-reference/adapters/routing-with-next-routing", "page_title": "Routing with @next/routing", "page_type": "api", "page_summary": "Explains how to use the `@next/routing` package's `resolveRoutes()` function to reproduce Next.js route matching behavior with data from `onBuildComplete`.", "heading": "Routing with @next/routing", "content": "Page: Routing with @next/routing\nSection: Routing with @next/routing\n\nYou can use `@next/routing` to reproduce Next.js route matching behavior with data from `onBuildComplete`.\n\n`resolveRoutes()` returns:\n\n- `middlewareResponded`: `true` when middleware already sent a…", "code_blocks": [{"language": "javascript", "code": "import { resolveRoutes } from '@next/routing'\n \nconst pathnames = [\n  ...outputs.pages,\n  ...outputs.pagesApi,\n  ...outputs.appPages,\n  ...outputs.appRoutes,\n  ...outputs.staticFiles,\n].map((output)…", "filename": ""}], "chunk_position": 12, "heading_path": "Routing with @next/routing > Routing with @next/routing", "breadcrumbs": "Routing with @next/routing > Routing with @next/routing > Routing with @next/routing"}, {"id": "41e3f3bcffc4e6fc", "url": "https://nextjs.org/docs/app/api-reference/adapters/runtime-integration", "page_title": "Runtime Integration", "page_type": "api", "page_summary": "Describes the runtime behavior of Next.js server and cache interfaces, and how adapters interact with them, including handler context and PPR chain headers.", "heading": "Overview", "content": "Page: Runtime Integration\nSection: Overview\n\nThe Deployment Adapter API is a **build-time** interface. It tells your platform what was built and how to route requests. **Runtime** behavior (request handling, streaming, caching) is handled by…", "code_blocks": [], "chunk_position": 13, "heading_path": "Overview > Overview", "breadcrumbs": "Runtime Integration > Overview > Overview"}, {"id": "24ec6b5b7d9e6783", "url": "https://nextjs.org/docs/app/api-reference/adapters/runtime-integration", "page_title": "Runtime Integration", "page_type": "api", "page_summary": "Describes the runtime behavior of Next.js server and cache interfaces, and how adapters interact with them, including handler context and PPR chain headers.", "heading": "Handler Context", "content": "Page: Runtime Integration\nSection: Handler Context\n\nWhen invoking entrypoints, adapters pass a `ctx` object to the Next.js handler. Key fields include:\n\n- **`ctx.waitUntil`**: a function that accepts a promise. Use this to keep the serverless function…", "code_blocks": [], "chunk_position": 13, "heading_path": "Handler Context > Handler Context", "breadcrumbs": "Runtime Integration > Handler Context > Handler Context"}, {"id": "8230a10a5672c3d6", "url": "https://nextjs.org/docs/app/api-reference/adapters/runtime-integration", "page_title": "Runtime Integration", "page_type": "api", "page_summary": "Describes the runtime behavior of Next.js server and cache interfaces, and how adapters interact with them, including handler context and PPR chain headers.", "heading": "PPR Chain Headers", "content": "Page: Runtime Integration\nSection: PPR Chain Headers\n\nIn the [prerenders output type](/docs/app/api-reference/adapters/output-types#prerenders-outputsprerenders), `pprChain.headers` contains the headers needed for the [resume…", "code_blocks": [], "chunk_position": 13, "heading_path": "PPR Chain Headers > PPR Chain Headers", "breadcrumbs": "Runtime Integration > PPR Chain Headers > PPR Chain Headers"}, {"id": "4ea5ee4063119936", "url": "https://nextjs.org/docs/app/api-reference/adapters/testing-adapters", "page_title": "Testing Adapters", "page_type": "guide", "page_summary": "Next.js provides a test harness for validating adapters, including end-to-end tests for deployment. This page describes the environment variables and script contracts required for custom deploy,…", "heading": "Testing Adapters", "content": "Page: Testing Adapters\nSection: Testing Adapters\n\nNext.js provides a test harness for validating adapters. Running the end-to-end tests for deployment.\n\nExample GitHub Actions workflow:\n\nThe test harness looks for these environment variables:\n\n-…", "code_blocks": [{"language": "yaml", "code": "name: test-e2e-deploy\n \non:\n  workflow_dispatch:\n    inputs:\n      nextjsRef:\n        description: 'Next.js repo ref (branch/tag/SHA)'\n        default: 'canary'\n        type: string\n  # schedule:\n  #…", "filename": ".github/workflows/test-e2e-deploy.yml"}], "chunk_position": 14, "heading_path": "Testing Adapters > Testing Adapters", "breadcrumbs": "Testing Adapters > Testing Adapters > Testing Adapters"}, {"id": "9cc4e8196f3118d9", "url": "https://nextjs.org/docs/app/api-reference/adapters/testing-adapters", "page_title": "Testing Adapters", "page_type": "guide", "page_summary": "Next.js provides a test harness for validating adapters, including end-to-end tests for deployment. This page describes the environment variables and script contracts required for custom deploy,…", "heading": "Custom deploy script contract", "content": "Page: Testing Adapters\nSection: Custom deploy script contract\n\nThe deploy script `NEXT_TEST_DEPLOY_SCRIPT_PATH` is executed with `cwd` set to the isolated temporary app created by the Next.js test harness.\n\nThe deploy script must follow this contract:\n\n- Exit…", "code_blocks": [{"language": "bash", "code": "#!/usr/bin/env bash\nset -euo pipefail\n \n# Install the adapter, build the app, and deploy or start it.\nnode -e \"\nconst…", "filename": "scripts/e2e-deploy.sh"}], "chunk_position": 14, "heading_path": "Custom deploy script contract > Custom deploy script contract", "breadcrumbs": "Testing Adapters > Custom deploy script contract > Custom deploy script contract"}, {"id": "9b222946dd8afad4", "url": "https://nextjs.org/docs/app/api-reference/adapters/testing-adapters", "page_title": "Testing Adapters", "page_type": "guide", "page_summary": "Next.js provides a test harness for validating adapters, including end-to-end tests for deployment. This page describes the environment variables and script contracts required for custom deploy,…", "heading": "Custom logs script contract", "content": "Page: Testing Adapters\nSection: Custom logs script contract\n\nThe logs script `NEXT_TEST_DEPLOY_LOGS_SCRIPT_PATH` is executed with `cwd` set to the isolated temporary app created by the Next.js test harness.\n\nAdditionally it receives `NEXT_TEST_DIR` and…", "code_blocks": [{"language": "bash", "code": "#!/usr/bin/env bash\nset -euo pipefail\n \nif [ -f \".adapter-build.log\" ]; then\n  cat \".adapter-build.log\"\nfi\n \nif [ -f \".adapter-server.log\" ]; then\n  echo \"=== .adapter-server.log ===\"\n  cat…", "filename": "scripts/e2e-logs.sh"}], "chunk_position": 14, "heading_path": "Custom logs script contract > Custom logs script contract", "breadcrumbs": "Testing Adapters > Custom logs script contract > Custom logs script contract"}, {"id": "d60fde46d21a3e24", "url": "https://nextjs.org/docs/app/api-reference/adapters/testing-adapters", "page_title": "Testing Adapters", "page_type": "guide", "page_summary": "Next.js provides a test harness for validating adapters, including end-to-end tests for deployment. This page describes the environment variables and script contracts required for custom deploy,…", "heading": "Custom cleanup script contract", "content": "Page: Testing Adapters\nSection: Custom cleanup script contract\n\nThe cleanup script `NEXT_TEST_CLEANUP_SCRIPT_PATH` is executed with `cwd` set to the isolated temporary app created by the Next.js test harness.\n\nAdditionally it receives `NEXT_TEST_DIR` and…", "code_blocks": [], "chunk_position": 14, "heading_path": "Custom cleanup script contract > Custom cleanup script contract", "breadcrumbs": "Testing Adapters > Custom cleanup script contract > Custom cleanup script contract"}, {"id": "12f09acef880747b", "url": "https://nextjs.org/docs/app/api-reference/adapters/use-cases", "page_title": "Adapters: Use Cases | Next.js", "page_type": "guide", "page_summary": "Common use cases for Next.js adapters, including deployment platform integration, asset processing, monitoring, custom bundling, build validation, and route generation.", "heading": "Use Cases", "content": "Page: Adapters: Use Cases | Next.js\nSection: Use Cases\n\nCommon use cases for adapters include:\n\n- **Deployment Platform Integration** : Automatically configure build outputs for specific hosting platforms\n\n- **Asset Processing** : Transform or optimize…", "code_blocks": [], "chunk_position": 15, "heading_path": "Use Cases > Use Cases", "breadcrumbs": "Adapters: Use Cases | Next.js > Use Cases > Use Cases"}, {"id": "a49d4d545ee28f33", "url": "https://nextjs.org/docs/app/api-reference/cli", "page_title": "API Reference: CLI | Next.js", "page_type": "reference", "page_summary": "Overview of the two Next.js Command Line Interface (CLI) tools: create-next-app and next, with links to their API references.", "heading": "CLI", "content": "Page: API Reference: CLI | Next.js\nSection: CLI\n\nNext.js comes with **two** Command Line Interface (CLI) tools:\n\n- **`create-next-app`**: Quickly create a new Next.js application using the default template or an…", "code_blocks": [], "chunk_position": 16, "heading_path": "CLI > CLI", "breadcrumbs": "API Reference: CLI | Next.js > CLI > CLI"}, {"id": "1a792862cf8786ef", "url": "https://nextjs.org/docs/app/api-reference/cli", "page_title": "API Reference: CLI | Next.js", "page_type": "reference", "page_summary": "Overview of the two Next.js Command Line Interface (CLI) tools: create-next-app and next, with links to their API references.", "heading": "create-next-app", "content": "Page: API Reference: CLI | Next.js\nSection: create-next-app\n\nCreate Next.js apps using one command with the create-next-app CLI.", "code_blocks": [], "chunk_position": 16, "heading_path": "create-next-app > create-next-app", "breadcrumbs": "API Reference: CLI | Next.js > create-next-app > create-next-app"}, {"id": "c7ab804bb7da2ac4", "url": "https://nextjs.org/docs/app/api-reference/cli", "page_title": "API Reference: CLI | Next.js", "page_type": "reference", "page_summary": "Overview of the two Next.js Command Line Interface (CLI) tools: create-next-app and next, with links to their API references.", "heading": "next CLI", "content": "Page: API Reference: CLI | Next.js\nSection: next CLI\n\nLearn how to run and build your application with the Next.js CLI.", "code_blocks": [], "chunk_position": 16, "heading_path": "next CLI > next CLI", "breadcrumbs": "API Reference: CLI | Next.js > next CLI > next CLI"}, {"id": "f75bfdce79c0baf9", "url": "https://nextjs.org/docs/app/api-reference/cli/create-next-app", "page_title": "create-next-app", "page_type": "api", "page_summary": "The create-next-app CLI allows you to create a new Next.js application using the default template or an example from a public GitHub repository. It is the easiest way to get started with Next.js.", "heading": "Basic usage", "content": "Page: create-next-app\nSection: Basic usage\n\n```bash\npnpm create next-app [project-name] [options]\n```", "code_blocks": [{"language": "bash", "code": "pnpm create next-app [project-name] [options]", "filename": ""}], "chunk_position": 17, "heading_path": "Basic usage > Basic usage", "breadcrumbs": "create-next-app > Basic usage > Basic usage"}, {"id": "136386e911c5c3b7", "url": "https://nextjs.org/docs/app/api-reference/cli/create-next-app", "page_title": "create-next-app", "page_type": "api", "page_summary": "The create-next-app CLI allows you to create a new Next.js application using the default template or an example from a public GitHub repository. It is the easiest way to get started with Next.js.", "heading": "With the default template", "content": "Page: create-next-app\nSection: With the default template\n\nTo create a new app using the default template, run the following command in your terminal:\n\nOn installation, you'll see the following prompts:\n\nIf you choose to `customize settings`, you'll see the…", "code_blocks": [{"language": "bash", "code": "pnpm create next-app", "filename": ""}, {"language": "text", "code": "What is your project named? my-app\nWould you like to use the recommended Next.js defaults?\n    Yes, use recommended defaults - TypeScript, ESLint, Tailwind CSS, App Router, AGENTS.md\n    No, reuse…", "filename": ""}, {"language": "text", "code": "Would you like to use TypeScript? No / Yes\nWhich linter would you like to use? ESLint / Biome / None\nWould you like to use React Compiler? No / Yes\nWould you like to use Tailwind CSS? No / Yes\nWould…", "filename": ""}], "chunk_position": 17, "heading_path": "With the default template > With the default template", "breadcrumbs": "create-next-app > With the default template > With the default template"}, {"id": "91194c23573d753f", "url": "https://nextjs.org/docs/app/api-reference/cli/create-next-app", "page_title": "create-next-app", "page_type": "api", "page_summary": "The create-next-app CLI allows you to create a new Next.js application using the default template or an example from a public GitHub repository. It is the easiest way to get started with Next.js.", "heading": "Linter Options", "content": "Page: create-next-app\nSection: Linter Options\n\n**ESLint** : The traditional and most popular JavaScript linter. Includes Next.js-specific rules from `@next/eslint-plugin-next`.\n\n **Biome** : A fast, modern linter and formatter that combines the…", "code_blocks": [], "chunk_position": 17, "heading_path": "Linter Options > Linter Options", "breadcrumbs": "create-next-app > Linter Options > Linter Options"}, {"id": "87ecb58e77bf1737", "url": "https://nextjs.org/docs/app/api-reference/cli/create-next-app", "page_title": "create-next-app", "page_type": "api", "page_summary": "The create-next-app CLI allows you to create a new Next.js application using the default template or an example from a public GitHub repository. It is the easiest way to get started with Next.js.", "heading": "With an official Next.js example", "content": "Page: create-next-app\nSection: With an official Next.js example\n\nTo create a new app using an official Next.js example, use the `--example` flag. For example:\n\nYou can view a list of all available examples along with setup instructions in the [Next.js…", "code_blocks": [{"language": "bash", "code": "pnpm create next-app --example [example-name] [your-project-name]", "filename": ""}], "chunk_position": 17, "heading_path": "With an official Next.js example > With an official Next.js example", "breadcrumbs": "create-next-app > With an official Next.js example > With an official Next.js example"}, {"id": "80e47d9efc35a874", "url": "https://nextjs.org/docs/app/api-reference/cli/create-next-app", "page_title": "create-next-app", "page_type": "api", "page_summary": "The create-next-app CLI allows you to create a new Next.js application using the default template or an example from a public GitHub repository. It is the easiest way to get started with Next.js.", "heading": "With any public GitHub example", "content": "Page: create-next-app\nSection: With any public GitHub example\n\nTo create a new app using any public GitHub example, use the `--example` option with the GitHub repository's URL. For example:", "code_blocks": [{"language": "bash", "code": "pnpm create next-app --example \"https://github.com/.../\" [your-project-name]", "filename": ""}], "chunk_position": 17, "heading_path": "With any public GitHub example > With any public GitHub example", "breadcrumbs": "create-next-app > With any public GitHub example > With any public GitHub example"}, {"id": "2c8f53daf00d0e7b", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "Basic Usage", "content": "Page: next CLI\nSection: Basic Usage\n\nThe Next.js CLI allows you to develop, build, start your application, and more. Basic usage:\n\n> **Good to know** : With `npm run`, use `--` before CLI flags so npm forwards them to `next`. This is…", "code_blocks": [{"language": "terminal", "code": "pnpm next [command] [options]", "filename": ""}], "chunk_position": 18, "heading_path": "Basic Usage > Basic Usage", "breadcrumbs": "next CLI > Basic Usage > Basic Usage"}, {"id": "2749511c270d1e4e", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "Reference", "content": "Page: next CLI\nSection: Reference\n\nThe following options are available:\n\n| Options | Description |\n| --- | --- |\n| `-h` or `--help` | Shows all available options |\n| `-v` or `--version` | Outputs the Next.js version number |", "code_blocks": [], "chunk_position": 18, "heading_path": "Reference > Reference", "breadcrumbs": "next CLI > Reference > Reference"}, {"id": "dda8e8aa688444f0", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "Commands", "content": "Page: next CLI\nSection: Commands\n\nThe following commands are available:\n\n| Command | Description |\n| --- | --- |\n| [`dev`](#next-dev-options) | Starts Next.js in development mode with Hot Module Reloading, error reporting, and more.…", "code_blocks": [], "chunk_position": 18, "heading_path": "Commands > Commands", "breadcrumbs": "next CLI > Commands > Commands"}, {"id": "a9250a08ec7c86a7", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "next dev options", "content": "Page: next CLI\nSection: next dev options\n\n`next dev` starts the application in development mode with Hot Module Reloading (HMR), error reporting, and more.\n\n> **Good to know** : Development builds output to `.next/dev` instead of `.next`.…", "code_blocks": [], "chunk_position": 18, "heading_path": "next dev options > next dev options", "breadcrumbs": "next CLI > next dev options > next dev options"}, {"id": "d34e6df3832fcc89", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "next build options", "content": "Page: next CLI\nSection: next build options\n\n`next build` creates an optimized production build of your application. The output displays information about each route. For example:\n\n```\nRoute (app)\n┌ ○ /_not-found\n└ ƒ /products/[id]\n \n○…", "code_blocks": [{"language": "terminal", "code": "Route (app)\n┌ ○ /_not-found\n└ ƒ /products/[id]\n \n○  (Static)   prerendered as static content\nƒ  (Dynamic)  server-rendered on demand", "filename": ""}], "chunk_position": 18, "heading_path": "next build options > next build options", "breadcrumbs": "next CLI > next build options > next build options"}, {"id": "3afa73e866f6db55", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "next start options", "content": "Page: next CLI\nSection: next start options\n\n`next start` starts the application in production mode. The application should be compiled with [`next build`](#next-build-options) first.\n\nThe following options are available for the `next start`…", "code_blocks": [], "chunk_position": 18, "heading_path": "next start options > next start options", "breadcrumbs": "next CLI > next start options > next start options"}, {"id": "e0a90add63697b1c", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "next info options", "content": "Page: next CLI\nSection: next info options\n\n`next info` prints relevant details about the current system which can be used to report Next.js bugs when opening a [GitHub issue](https://github.com/vercel/next.js/issues). This information…", "code_blocks": [{"language": "terminal", "code": "Operating System:\n  Platform: darwin\n  Arch: arm64\n  Version: Darwin Kernel Version 23.6.0\n  Available memory (MB): 65536\n  Available CPU cores: 10\nBinaries:\n  Node: 20.12.0\n  npm: 10.5.0\n  Yarn:…", "filename": ""}], "chunk_position": 18, "heading_path": "next info options > next info options", "breadcrumbs": "next CLI > next info options > next info options"}, {"id": "3df0a0eda8221b37", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "next telemetry options", "content": "Page: next CLI\nSection: next telemetry options\n\nNext.js collects  **completely anonymous**  telemetry data about general usage. Participation in this anonymous program is optional, and you can opt-out if you prefer not to share information.\n\nThe…", "code_blocks": [], "chunk_position": 18, "heading_path": "next telemetry options > next telemetry options", "breadcrumbs": "next CLI > next telemetry options > next telemetry options"}, {"id": "34ce949e7f181899", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "next typegen options", "content": "Page: next CLI\nSection: next typegen options\n\n`next typegen` generates TypeScript definitions for your application's routes without performing a full build. This is useful for IDE autocomplete and CI type-checking of route usage.\n\nPreviously,…", "code_blocks": [{"language": "terminal", "code": "# Generate route types first, then validate with TypeScript\nnext typegen && tsc --noEmit\n\n# Or in CI workflows for type checking without building\nnext typegen && npm run type-check", "filename": ""}, {"language": "terminal", "code": "next typegen\n# or for a specific app\nnext typegen ./apps/web", "filename": ""}], "chunk_position": 18, "heading_path": "next typegen options > next typegen options", "breadcrumbs": "next CLI > next typegen options > next typegen options"}, {"id": "e1eb304d0d16837e", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "next upgrade options", "content": "Page: next CLI\nSection: next upgrade options\n\n`next upgrade` upgrades your Next.js application to the latest version.\n\nThe following options are available for the `next upgrade` command:\n\n| Option | Description |\n| --- | --- |\n| `-h, --help` |…", "code_blocks": [], "chunk_position": 18, "heading_path": "next upgrade options > next upgrade options", "breadcrumbs": "next CLI > next upgrade options > next upgrade options"}, {"id": "d3e6bf231dc59346", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "next experimental-analyze options", "content": "Page: next CLI\nSection: next experimental-analyze options\n\n`next experimental-analyze` analyzes your application's bundle output using [Turbopack](/docs/app/api-reference/turbopack). This command helps you understand the size and composition of your bundles,…", "code_blocks": [{"language": "terminal", "code": "pnpm next experimental-analyze", "filename": ""}, {"language": "terminal", "code": "# Write output to .next/diagnostics/analyze\nnpx next experimental-analyze --output\n\n# Copy the output for comparison with a future analysis\ncp -r .next/diagnostics/analyze ./analyze-before-refactor", "filename": ""}], "chunk_position": 18, "heading_path": "next experimental-analyze options > next experimental-analyze options", "breadcrumbs": "next CLI > next experimental-analyze options > next experimental-analyze options"}, {"id": "d1efb6f1c3410804", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "Debugging prerender errors", "content": "Page: next CLI\nSection: Debugging prerender errors\n\nIf you encounter prerendering errors during `next build`, you can pass the `--debug-prerender` flag to get more detailed output:\n\n```\nnext build --debug-prerender\n```\n\nThis enables several…", "code_blocks": [{"language": "terminal", "code": "next build --debug-prerender", "filename": ""}], "chunk_position": 18, "heading_path": "Debugging prerender errors > Debugging prerender errors", "breadcrumbs": "next CLI > Debugging prerender errors > Debugging prerender errors"}, {"id": "91837272b373348a", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "Building specific routes", "content": "Page: next CLI\nSection: Building specific routes\n\nYou can build only specific routes in the App and Pages Routers using the `--debug-build-paths` option. This is useful for faster debugging when working with large applications. The…", "code_blocks": [{"language": "terminal", "code": "# Build a specific route\nnext build --debug-build-paths=\"app/page.tsx\"\n\n# Build more than one route\nnext build --debug-build-paths=\"app/page.tsx,pages/index.tsx\"\n\n# Include route group folders in the…", "filename": ""}], "chunk_position": 18, "heading_path": "Building specific routes > Building specific routes", "breadcrumbs": "next CLI > Building specific routes > Building specific routes"}, {"id": "86fa96eb78addb75", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "Changing the default port", "content": "Page: next CLI\nSection: Changing the default port\n\nBy default, Next.js uses `http://localhost:3000` during development and with `next start`. The default port can be changed with the `-p` option, like so:\n\n```\nnext dev -p 4000\n```\n\nOr using the…", "code_blocks": [{"language": "terminal", "code": "next dev -p 4000", "filename": ""}, {"language": "terminal", "code": "PORT=4000 next dev", "filename": ""}], "chunk_position": 18, "heading_path": "Changing the default port > Changing the default port", "breadcrumbs": "next CLI > Changing the default port > Changing the default port"}, {"id": "b2136f2a4925ff4e", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "Using HTTPS during development", "content": "Page: next CLI\nSection: Using HTTPS during development\n\nFor certain use cases like webhooks or authentication, you can use [HTTPS](https://developer.mozilla.org/en-US/docs/Glossary/HTTPS) to have a secure environment on `localhost`. Next.js can generate a…", "code_blocks": [{"language": "terminal", "code": "next dev --experimental-https", "filename": ""}, {"language": "terminal", "code": "next dev --experimental-https --experimental-https-key ./certificates/localhost-key.pem --experimental-https-cert ./certificates/localhost.pem", "filename": ""}], "chunk_position": 18, "heading_path": "Using HTTPS during development > Using HTTPS during development", "breadcrumbs": "next CLI > Using HTTPS during development > Using HTTPS during development"}, {"id": "4125f8124c6ef37c", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "Configuring a timeout for downstream proxies", "content": "Page: next CLI\nSection: Configuring a timeout for downstream proxies\n\nWhen deploying Next.js behind a downstream proxy (e.g. a load-balancer like AWS ELB/ALB), it's important to configure Next's underlying HTTP server with [keep-alive…", "code_blocks": [{"language": "terminal", "code": "next start --keepAliveTimeout 70000", "filename": ""}], "chunk_position": 18, "heading_path": "Configuring a timeout for downstream proxies > Configuring a timeout for downstream proxies", "breadcrumbs": "next CLI > Configuring a timeout for downstream proxies > Configuring a timeout for downstream proxies"}, {"id": "aa54a941b3c3d89f", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "Passing Node.js arguments", "content": "Page: next CLI\nSection: Passing Node.js arguments\n\nYou can pass any [node arguments](https://nodejs.org/api/cli.html#cli_node_options_options) to `next` commands. For example:\n\n```\nNODE_OPTIONS='--throw-deprecation' next\nNODE_OPTIONS='-r esm'…", "code_blocks": [{"language": "terminal", "code": "NODE_OPTIONS='--throw-deprecation' next\nNODE_OPTIONS='-r esm' next\nNODE_OPTIONS='--inspect' next", "filename": ""}], "chunk_position": 18, "heading_path": "Passing Node.js arguments > Passing Node.js arguments", "breadcrumbs": "next CLI > Passing Node.js arguments > Passing Node.js arguments"}, {"id": "e8479b1629ffc664", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "CPU profiling", "content": "Page: next CLI\nSection: CPU profiling\n\nYou can capture CPU profiles to analyze performance bottlenecks in your Next.js application. The `--experimental-cpu-prof` flag enables V8's built-in CPU profiler and saves profiles to…", "code_blocks": [{"language": "terminal", "code": "# Profile the build process\nnext build --experimental-cpu-prof\n\n# Profile the dev server (profile saved on Ctrl+C or SIGTERM)\nnext dev --experimental-cpu-prof\n\n# Profile the production server\nnext…", "filename": ""}], "chunk_position": 18, "heading_path": "CPU profiling > CPU profiling", "breadcrumbs": "next CLI > CPU profiling > CPU profiling"}, {"id": "3c0cd84dbecc78bd", "url": "https://nextjs.org/docs/app/api-reference/cli/next", "page_title": "next CLI", "page_type": "api", "page_summary": "The Next.js CLI allows you to develop, build, start your application, and more. It provides commands like dev, build, start, info, telemetry, typegen, upgrade, and experimental-analyze.", "heading": "Version History", "content": "Page: next CLI\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v16.1.0` | Add the `next upgrade` command |\n| `v16.1.0` | Add the `next experimental-analyze` command |\n| `v16.0.0` | The JS bundle size metrics have been…", "code_blocks": [], "chunk_position": 18, "heading_path": "Version History > Version History", "breadcrumbs": "next CLI > Version History > Version History"}, {"id": "c5a12be468e70a7a", "url": "https://nextjs.org/docs/app/api-reference/components", "page_title": "Components", "page_type": "overview", "page_summary": "This page provides an index of Next.js built-in components for optimizing fonts, forms, images, links, and scripts.", "heading": "Components", "content": "Page: Components\nSection: Components\n\nThis page is also available as Markdown: request this page's URL with an `Accept: text/markdown` header. For an index of Next.js documentation, see [/docs/llms.txt](/docs/llms.txt).\n\n- [Font:…", "code_blocks": [], "chunk_position": 19, "heading_path": "Components > Components", "breadcrumbs": "Components > Components > Components"}, {"id": "328d35585f6a7d64", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "Reference", "content": "Page: Font Module\nSection: Reference\n\nThe following table lists the available options for the font loader functions. The columns indicate which loader (`font/google` or `font/local`) each option applies to, the type, and whether it is…", "code_blocks": [], "chunk_position": 20, "heading_path": "Reference > Reference", "breadcrumbs": "Font Module > Reference > Reference"}, {"id": "910086b5823cd873", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "src", "content": "Page: Font Module\nSection: src\n\nThe path of the font file as a string or an array of objects (with type `Array<{path: string, weight?: string, style?: string}>`) relative to the directory where the font loader function is…", "code_blocks": [], "chunk_position": 20, "heading_path": "src > src", "breadcrumbs": "Font Module > src > src"}, {"id": "fbc56a2fcb96e4a9", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "weight", "content": "Page: Font Module\nSection: weight\n\nThe font [`weight`](https://fonts.google.com/knowledge/glossary/weight) with the following possibilities:\n\n- A string with possible values of the weights available for the specific font or a range of…", "code_blocks": [], "chunk_position": 20, "heading_path": "weight > weight", "breadcrumbs": "Font Module > weight > weight"}, {"id": "ab4ebaead49031e9", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "style", "content": "Page: Font Module\nSection: style\n\nThe font [`style`](https://developer.mozilla.org/docs/Web/CSS/font-style) with the following possibilities:\n\n- A string [value](https://developer.mozilla.org/docs/Web/CSS/font-style#values) with…", "code_blocks": [], "chunk_position": 20, "heading_path": "style > style", "breadcrumbs": "Font Module > style > style"}, {"id": "2774d25a2e702888", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "subsets", "content": "Page: Font Module\nSection: subsets\n\nThe font [`subsets`](https://fonts.google.com/knowledge/glossary/subsetting) defined by an array of string values with the names of each subset you would like to be…", "code_blocks": [], "chunk_position": 20, "heading_path": "subsets > subsets", "breadcrumbs": "Font Module > subsets > subsets"}, {"id": "ce839b0bf6ade8e3", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "axes", "content": "Page: Font Module\nSection: axes\n\nSome variable fonts have extra `axes` that can be included. By default, only the font weight is included to keep the file size down. The possible values of `axes` depend on the specific font.\n\nUsed…", "code_blocks": [], "chunk_position": 20, "heading_path": "axes > axes", "breadcrumbs": "Font Module > axes > axes"}, {"id": "5d71ecdfb56df3e9", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "display", "content": "Page: Font Module\nSection: display\n\nThe font [`display`](https://developer.mozilla.org/docs/Web/CSS/@font-face/font-display) with possible string [values](https://developer.mozilla.org/docs/Web/CSS/@font-face/font-display#values) of…", "code_blocks": [], "chunk_position": 20, "heading_path": "display > display", "breadcrumbs": "Font Module > display > display"}, {"id": "71310a66ee730e51", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "preload", "content": "Page: Font Module\nSection: preload\n\nA boolean value that specifies whether the font should be [preloaded](/docs/app/api-reference/components/font#preloading) or not. The default is `true`.\n\nUsed in `next/font/google` and…", "code_blocks": [], "chunk_position": 20, "heading_path": "preload > preload", "breadcrumbs": "Font Module > preload > preload"}, {"id": "f153a631d1868db1", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "fallback", "content": "Page: Font Module\nSection: fallback\n\nThe fallback font to use if the font cannot be loaded. An array of strings of fallback fonts with no default.\n\n- Optional\n\nUsed in `next/font/google` and `next/font/local`\n\nExamples:\n\n- `fallback:…", "code_blocks": [], "chunk_position": 20, "heading_path": "fallback > fallback", "breadcrumbs": "Font Module > fallback > fallback"}, {"id": "8db5261363937f36", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "adjustFontFallback", "content": "Page: Font Module\nSection: adjustFontFallback\n\n- For `next/font/google`: A boolean value that sets whether an automatic fallback font should be used to reduce [Cumulative Layout Shift](https://web.dev/cls/). The default is `true`.\n\n- For…", "code_blocks": [], "chunk_position": 20, "heading_path": "adjustFontFallback > adjustFontFallback", "breadcrumbs": "Font Module > adjustFontFallback > adjustFontFallback"}, {"id": "2cc19cb909b296d4", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "variable", "content": "Page: Font Module\nSection: variable\n\nA string value to define the CSS variable name to be used if the style is applied with the [CSS variable method](#css-variables).\n\nUsed in `next/font/google` and `next/font/local`\n\n-…", "code_blocks": [], "chunk_position": 20, "heading_path": "variable > variable", "breadcrumbs": "Font Module > variable > variable"}, {"id": "5f05d9e7fc3fa829", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "declarations", "content": "Page: Font Module\nSection: declarations\n\nAn array of font face [descriptor](https://developer.mozilla.org/docs/Web/CSS/@font-face#descriptors) key-value pairs that define the generated `@font-face` further.\n\nUsed in `next/font/local`\n\n-…", "code_blocks": [], "chunk_position": 20, "heading_path": "declarations > declarations", "breadcrumbs": "Font Module > declarations > declarations"}, {"id": "70d89098084a56fa", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "Google Fonts", "content": "Page: Font Module\nSection: Google Fonts\n\nTo use a Google font, import it from `next/font/google` as a function. We recommend using [variable fonts](https://fonts.google.com/variablefonts) for the best performance and flexibility.\n\nIf you…", "code_blocks": [{"language": "tsx", "code": "import { Inter } from 'next/font/google'\n \n// If loading a variable font, you don't need to specify the font weight\nconst inter = Inter({\n  subsets: ['latin'],\n  display: 'swap',\n})\n \nexport default…", "filename": "app/layout.tsx"}, {"language": "tsx", "code": "import { Roboto } from 'next/font/google'\n \nconst roboto = Roboto({\n  weight: '400',\n  subsets: ['latin'],\n  display: 'swap',\n})\n \nexport default function RootLayout({\n  children,\n}: {\n  children:…", "filename": "app/layout.tsx"}, {"language": "js", "code": "const roboto = Roboto({\n  weight: ['400', '700'],\n  style: ['normal', 'italic'],\n  subsets: ['latin'],\n  display: 'swap',\n})", "filename": "app/layout.js"}], "chunk_position": 20, "heading_path": "Google Fonts > Google Fonts", "breadcrumbs": "Font Module > Google Fonts > Google Fonts"}, {"id": "ac7331093766e293", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "Specifying a subset", "content": "Page: Font Module\nSection: Specifying a subset\n\nGoogle Fonts are automatically [subset](https://fonts.google.com/knowledge/glossary/subsetting). This reduces the size of the font file and improves performance. You'll need to define which of these…", "code_blocks": [{"language": "tsx", "code": "const inter = Inter({ subsets: ['latin'] })", "filename": "app/layout.tsx"}], "chunk_position": 20, "heading_path": "Specifying a subset > Specifying a subset", "breadcrumbs": "Font Module > Specifying a subset > Specifying a subset"}, {"id": "bd7f82d84b6ea335", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "Using Multiple Fonts", "content": "Page: Font Module\nSection: Using Multiple Fonts\n\nYou can import and use multiple fonts in your application. There are two approaches you can take.\n\nThe first approach is to create a utility function that exports a font, imports it, and applies its…", "code_blocks": [{"language": "tsx", "code": "import { Inter, Roboto_Mono } from 'next/font/google'\n \nexport const inter = Inter({\n  subsets: ['latin'],\n  display: 'swap',\n})\n \nexport const roboto_mono = Roboto_Mono({\n  subsets: ['latin'],…", "filename": "app/fonts.ts"}, {"language": "tsx", "code": "import { inter } from './fonts'\n \nexport default function Layout({ children }: { children: React.ReactNode }) {\n  return (\n    <html lang=\"en\" className={inter.className}>\n      <body>…", "filename": "app/layout.tsx"}, {"language": "tsx", "code": "import { roboto_mono } from './fonts'\n \nexport default function Page() {\n  return (\n    <>\n      <h1 className={roboto_mono.className}>My page</h1>\n    </>\n  )\n}", "filename": "app/page.tsx"}, {"language": "tsx", "code": "import { Inter, Roboto_Mono } from 'next/font/google'\nimport styles from './global.css'\n \nconst inter = Inter({\n  subsets: ['latin'],\n  variable: '--font-inter',\n  display: 'swap',\n})\n \nconst…", "filename": "app/layout.tsx"}, {"language": "css", "code": "html {\n  font-family: var(--font-inter);\n}\n \nh1 {\n  font-family: var(--font-roboto-mono);\n}", "filename": "app/global.css"}], "chunk_position": 20, "heading_path": "Using Multiple Fonts > Using Multiple Fonts", "breadcrumbs": "Font Module > Using Multiple Fonts > Using Multiple Fonts"}, {"id": "64291e30fe9ef62e", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "Local Fonts", "content": "Page: Font Module\nSection: Local Fonts\n\nImport `next/font/local` and specify the `src` of your local font file. We recommend using [variable fonts](https://fonts.google.com/variablefonts) for the best performance and flexibility.\n\nIf you…", "code_blocks": [{"language": "tsx", "code": "import localFont from 'next/font/local'\n \n// Font files can be colocated inside of `app`\nconst myFont = localFont({\n  src: './my-font.woff2',\n  display: 'swap',\n})\n \nexport default function…", "filename": "app/layout.tsx"}, {"language": "js", "code": "const roboto = localFont({\n  src: [\n    {\n      path: './Roboto-Regular.woff2',\n      weight: '400',\n      style: 'normal',\n    },\n    {\n      path: './Roboto-Italic.woff2',\n      weight: '400',…", "filename": ""}], "chunk_position": 20, "heading_path": "Local Fonts > Local Fonts", "breadcrumbs": "Font Module > Local Fonts > Local Fonts"}, {"id": "48f7446b8753b6fc", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "With Tailwind CSS", "content": "Page: Font Module\nSection: With Tailwind CSS\n\n`next/font` integrates seamlessly with [Tailwind CSS](https://tailwindcss.com/) using [CSS variables](/docs/app/api-reference/components/font#css-variables).\n\nIn the example below, we use the `Inter`…", "code_blocks": [{"language": "tsx", "code": "import { Inter, Roboto_Mono } from 'next/font/google'\n \nconst inter = Inter({\n  subsets: ['latin'],\n  display: 'swap',\n  variable: '--font-inter',\n})\n \nconst roboto_mono = Roboto_Mono({\n  subsets:…", "filename": "app/layout.tsx"}, {"language": "css", "code": "@import 'tailwindcss';\n \n@theme inline {\n  --font-sans: var(--font-inter);\n  --font-mono: var(--font-roboto-mono);\n}", "filename": "global.css"}, {"language": "js", "code": "/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n  content: [\n    './pages/**/*.{js,ts,jsx,tsx}',\n    './components/**/*.{js,ts,jsx,tsx}',\n    './app/**/*.{js,ts,jsx,tsx}',\n  ],…", "filename": "tailwind.config.js"}, {"language": "html", "code": "<p class=\"font-sans ...\">The quick brown fox ...</p>\n<p class=\"font-mono ...\">The quick brown fox ...</p>", "filename": ""}], "chunk_position": 20, "heading_path": "With Tailwind CSS > With Tailwind CSS", "breadcrumbs": "Font Module > With Tailwind CSS > With Tailwind CSS"}, {"id": "e8211623b9629c6f", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "Applying Styles", "content": "Page: Font Module\nSection: Applying Styles\n\nYou can apply the font styles in three ways:\n\n- [`className`](#classname)\n- [`style`](#style-1)\n- [CSS Variables](#css-variables)", "code_blocks": [], "chunk_position": 20, "heading_path": "Applying Styles > Applying Styles", "breadcrumbs": "Font Module > Applying Styles > Applying Styles"}, {"id": "5ceca495aa7bdeab", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "className", "content": "Page: Font Module\nSection: className\n\nReturns a read-only CSS `className` for the loaded font to be passed to an HTML element.", "code_blocks": [{"language": "jsx", "code": "<p className={inter.className}>Hello, Next.js!</p>", "filename": ""}], "chunk_position": 20, "heading_path": "className > className", "breadcrumbs": "Font Module > className > className"}, {"id": "8904e9adebaa1583", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "CSS Variables", "content": "Page: Font Module\nSection: CSS Variables\n\nIf you would like to set your styles in an external style sheet and specify additional options there, use the CSS variable method.\n\nIn addition to importing the font, also import the CSS file where…", "code_blocks": [{"language": "tsx", "code": "import { Inter } from 'next/font/google'\nimport styles from '../styles/component.module.css'\n \nconst inter = Inter({\n  variable: '--font-inter',\n})", "filename": "app/page.tsx"}, {"language": "tsx", "code": "<main className={inter.variable}>\n  <p className={styles.text}>Hello World</p>\n</main>", "filename": "app/page.tsx"}, {"language": "css", "code": ".text {\n  font-family: var(--font-inter);\n  font-weight: 200;\n  font-style: italic;\n}", "filename": "styles/component.module.css"}], "chunk_position": 20, "heading_path": "CSS Variables > CSS Variables", "breadcrumbs": "Font Module > CSS Variables > CSS Variables"}, {"id": "eb453931652078ad", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "Using a font definitions file", "content": "Page: Font Module\nSection: Using a font definitions file\n\nEvery time you call the `localFont` or Google font function, that font will be hosted as one instance in your application. Therefore, if you need to use the same font in multiple places, you should…", "code_blocks": [{"language": "tsx", "code": "import { Inter, Lora, Source_Sans_3 } from 'next/font/google'\nimport localFont from 'next/font/local'\n \n// define your variable fonts\nconst inter = Inter()\nconst lora = Lora()\n// define 2 weights of…", "filename": "styles/fonts.ts"}, {"language": "tsx", "code": "import { inter, lora, sourceCodePro700, greatVibes } from '../styles/fonts'\n \nexport default function Page() {\n  return (\n    <div>\n      <p className={inter.className}>Hello world using Inter…", "filename": "app/page.tsx"}, {"language": "json", "code": "{\n  \"compilerOptions\": {\n    \"paths\": {\n      \"@/fonts\": [\"./styles/fonts\"]\n    }\n  }\n}", "filename": "tsconfig.json"}, {"language": "tsx", "code": "import { greatVibes, sourceCodePro400 } from '@/fonts'", "filename": "app/about/page.tsx"}], "chunk_position": 20, "heading_path": "Using a font definitions file > Using a font definitions file", "breadcrumbs": "Font Module > Using a font definitions file > Using a font definitions file"}, {"id": "d1dc95c63a4bb077", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "Preloading", "content": "Page: Font Module\nSection: Preloading\n\nWhen a font function is called on a page of your site, it is not globally available and preloaded on all routes. Rather, the font is only preloaded on the related routes based on the type of file…", "code_blocks": [], "chunk_position": 20, "heading_path": "Preloading > Preloading", "breadcrumbs": "Font Module > Preloading > Preloading"}, {"id": "8bef6d43829b3c39", "url": "https://nextjs.org/docs/app/api-reference/components/font", "page_title": "Font Module", "page_type": "api", "page_summary": "This page documents the Next.js Font Module (`next/font`), which automatically optimizes fonts, self-hosts font files, and provides built-in support for Google Fonts. It covers the API reference for…", "heading": "Version Changes", "content": "Page: Font Module\nSection: Version Changes\n\nThe following table lists the version history for the Font Module.", "code_blocks": [], "chunk_position": 20, "heading_path": "Version Changes > Version Changes", "breadcrumbs": "Font Module > Version Changes > Version Changes"}, {"id": "8edc93ab7373ad5d", "url": "https://nextjs.org/docs/app/api-reference/components/form", "page_title": "Form Component", "page_type": "api", "page_summary": "The <Form> component extends the HTML <form> element to provide prefetching of loading UI, client-side navigation on submission, and progressive enhancement. It is useful for forms that update URL…", "heading": "Overview", "content": "Page: Form Component\nSection: Overview\n\nThe `<Form>` component extends the HTML `<form>` element to provide **prefetching** of loading UI, **client-side navigation** on submission, and **progressive enhancement**. It's useful for forms…", "code_blocks": [{"language": "tsx", "code": "import Form from 'next/form'\n \nexport default function Page() {\n  return (\n    <Form action=\"/search\">\n      {/* On submission, the input value will be appended to\n          the URL, e.g.…", "filename": "/app/ui/search.tsx"}], "chunk_position": 21, "heading_path": "Overview > Overview", "breadcrumbs": "Form Component > Overview > Overview"}, {"id": "82370306fdb848a3", "url": "https://nextjs.org/docs/app/api-reference/components/form", "page_title": "Form Component", "page_type": "api", "page_summary": "The <Form> component extends the HTML <form> element to provide prefetching of loading UI, client-side navigation on submission, and progressive enhancement. It is useful for forms that update URL…", "heading": "Reference", "content": "Page: Form Component\nSection: Reference\n\nThe behavior of the `<Form>` component depends on whether the `action` prop is passed a `string` or `function`.\n\n- When `action` is a **string**, the `<Form>` behaves like a native HTML form that…", "code_blocks": [], "chunk_position": 21, "heading_path": "Reference > Reference", "breadcrumbs": "Form Component > Reference > Reference"}, {"id": "9d5188ae75bdf2ac", "url": "https://nextjs.org/docs/app/api-reference/components/form", "page_title": "Form Component", "page_type": "api", "page_summary": "The <Form> component extends the HTML <form> element to provide prefetching of loading UI, client-side navigation on submission, and progressive enhancement. It is useful for forms that update URL…", "heading": "action (string) Props", "content": "Page: Form Component\nSection: action (string) Props\n\nWhen `action` is a string, the `<Form>` component supports the following props:\n\n- **`action`** : The URL or path to navigate to when the form is submitted. An empty string `\"\"` will navigate to the…", "code_blocks": [], "chunk_position": 21, "heading_path": "action (string) Props > action (string) Props", "breadcrumbs": "Form Component > action (string) Props > action (string) Props"}, {"id": "168a25f8073ad3ce", "url": "https://nextjs.org/docs/app/api-reference/components/form", "page_title": "Form Component", "page_type": "api", "page_summary": "The <Form> component extends the HTML <form> element to provide prefetching of loading UI, client-side navigation on submission, and progressive enhancement. It is useful for forms that update URL…", "heading": "action (function) Props", "content": "Page: Form Component\nSection: action (function) Props\n\nWhen `action` is a function, the `<Form>` component supports the following prop:\n\n- **`action`** : The Server Action to be called when the form is submitted. See the [React…", "code_blocks": [], "chunk_position": 21, "heading_path": "action (function) Props > action (function) Props", "breadcrumbs": "Form Component > action (function) Props > action (function) Props"}, {"id": "670b712dc806bcb0", "url": "https://nextjs.org/docs/app/api-reference/components/form", "page_title": "Form Component", "page_type": "api", "page_summary": "The <Form> component extends the HTML <form> element to provide prefetching of loading UI, client-side navigation on submission, and progressive enhancement. It is useful for forms that update URL…", "heading": "Caveats", "content": "Page: Form Component\nSection: Caveats\n\n- **`formAction`** : Can be used in a `<button>` or `<input type=\"submit\">` fields to override the `action` prop. Next.js will perform a client-side navigation, however, this approach doesn't support…", "code_blocks": [], "chunk_position": 21, "heading_path": "Caveats > Caveats", "breadcrumbs": "Form Component > Caveats > Caveats"}, {"id": "75aed204dde81e81", "url": "https://nextjs.org/docs/app/api-reference/components/form", "page_title": "Form Component", "page_type": "api", "page_summary": "The <Form> component extends the HTML <form> element to provide prefetching of loading UI, client-side navigation on submission, and progressive enhancement. It is useful for forms that update URL…", "heading": "Search form that leads to a search result page", "content": "Page: Form Component\nSection: Search form that leads to a search result page\n\nYou can create a search form that navigates to a search results page by passing the path as an `action`:\n\nWhen the user updates the query input field and submits the form, the form data will be…", "code_blocks": [{"language": "tsx", "code": "import Form from 'next/form'\n \nexport default function Page() {\n  return (\n    <Form action=\"/search\">\n      <input name=\"query\" />\n      <button type=\"submit\">Submit</button>\n    </Form>\n  )\n}", "filename": "/app/page.tsx"}, {"language": "tsx", "code": "import { getSearchResults } from '@/lib/search'\n \nexport default async function SearchPage({\n  searchParams,\n}: {\n  searchParams: Promise<{ [key: string]: string | string[] | undefined }>\n}) {…", "filename": "/app/search/page.tsx"}, {"language": "tsx", "code": "export default function Loading() {\n  return <div>Loading...</div>\n}", "filename": "/app/search/loading.tsx"}, {"language": "tsx", "code": "'use client'\nimport { useFormStatus } from 'react-dom'\n \nexport default function SearchButton() {\n  const status = useFormStatus()\n  return (\n    <button type=\"submit\">{status.pending ?…", "filename": "/app/ui/search-button.tsx"}, {"language": "tsx", "code": "import Form from 'next/form'\nimport { SearchButton } from '@/ui/search-button'\n \nexport default function Page() {\n  return (\n    <Form action=\"/search\">\n      <input name=\"query\" />…", "filename": "/app/page.tsx"}], "chunk_position": 21, "heading_path": "Search form that leads to a search result page > Search form that leads to a search result page", "breadcrumbs": "Form Component > Search form that leads to a search result page > Search form that leads to a search result page"}, {"id": "154bf5ab72f51c73", "url": "https://nextjs.org/docs/app/api-reference/components/form", "page_title": "Form Component", "page_type": "api", "page_summary": "The <Form> component extends the HTML <form> element to provide prefetching of loading UI, client-side navigation on submission, and progressive enhancement. It is useful for forms that update URL…", "heading": "Mutations with Server Actions", "content": "Page: Form Component\nSection: Mutations with Server Actions\n\nYou can perform mutations by passing a function to the `action` prop.\n\nAfter a mutation, it's common to redirect to the new resource. You can use the [`redirect`](/docs/app/guides/redirecting)…", "code_blocks": [{"language": "tsx", "code": "import Form from 'next/form'\nimport { createPost } from '@/posts/actions'\n \nexport default function Page() {\n  return (\n    <Form action={createPost}>\n      <input name=\"title\" />\n      {/* ... */}…", "filename": "/app/posts/create/page.tsx"}, {"language": "ts", "code": "'use server'\nimport { redirect } from 'next/navigation'\n \nexport async function createPost(formData: FormData) {\n  // Create a new post\n  // ...\n \n  // Redirect to the new post…", "filename": "/app/posts/actions.ts"}, {"language": "tsx", "code": "import { getPost } from '@/posts/data'\n \nexport default async function PostPage({\n  params,\n}: {\n  params: Promise<{ id: string }>\n}) {\n  const { id } = await params\n  const data = await getPost(id)…", "filename": "/app/posts/[id]/page.tsx"}], "chunk_position": 21, "heading_path": "Mutations with Server Actions > Mutations with Server Actions", "breadcrumbs": "Form Component > Mutations with Server Actions > Mutations with Server Actions"}, {"id": "8883f75bc1e22daf", "url": "https://nextjs.org/docs/app/api-reference/components/image", "page_title": "Components: Image Component | Next.js", "page_type": "reference", "page_summary": "Extraction fallback content.", "heading": "Components: Image Component | Next.js", "content": "Page: Components: Image Component | Next.js\nSection: Components: Image Component | Next.js\n\nThis page is also available as Markdown: request this page's URL with an `Accept: text/markdown` header.   For an index of  Next.js documentation , see  [/docs/llms.txt](/docs/llms.txt).Copy page\n\n##### Image Component\n\nLast updated  May 4, 2026\n\n\nThe Next.js Image component extends the HTML `<img>` element for automatic image optimization.\n\n\napp/page.js\n \n\n\n##### Reference\n\n\n\n\n###### Props\n\n\n\n\nThe following props are available:\n\n\n\n\n\n\n\n| Prop | Example | Type | Status |\n| --- | --- | --- | --- |\n\n\n\n\n| [`src`](#src) | `src=\"/profile.png\"` | String | Required |\n| [`alt`](#alt) | `alt=\"Picture of the author\"` | String | Required |\n| [`width`](#width-and-height) | `width={500}` | Integer (px) | - |\n| [`height`](#width-and-height) | `height={500}` | Integer (px) | - |\n| [`fill`](#fill) | `fill={true}` | Boolean | - |\n| [`loader`](#loader) | `loader={imageLoader}` | Function | - |\n| [`sizes`](#sizes) | `sizes=\"(max-width: 768px) 100vw, 33vw\"` | String | - |\n| [`quality`](#quality) | `quality={80}` | Integer (1-100) | - |\n| [`preload`](#preload) | `preload={true}` | Boolean | - |\n| [`placeholder`](#placeholder) | `placeholder=\"blur\"` | String | - |\n| [`style`](#style) | `style={{objectFit: \"contain\"}}` | Object | - |\n| [`onLoadingComplete`](#onloadingcomplete) | `onLoadingComplete={img => done())}` | Function | Deprecated |\n| [`onLoad`](#onload) | `onLoad={event => done())}` | Function | - |\n| [`onError`](#onerror) | `onError(event => fail()}` | Function | - |\n| [`loading`](#loading) | `loading=\"lazy\"` | String | - |\n| [`blurDataURL`](#blurdataurl) | `blurDataURL=\"data:image/jpeg...\"` | String | - |\n| [`unoptimized`](#unoptimized) | `unoptimized={true}` | Boolean | - |\n| [`overrideSrc`](#overridesrc) | `overrideSrc=\"/seo.png\"` | String | - |\n| [`decoding`](#decoding) | `decoding=\"async\"` | String | - |\n\n\n\n\n\n\n###### `src`\n\n\n\n\nThe source of the image. Can be one of the following:\n\n\n\n\nAn internal path string.\n\n\n\n\n\nAn absolute external URL (must be configured with [remotePatterns](#remotepatterns)).\n\n\n\n\n\nA static import.\n\n\n\n\n\n> **Good to know** : For security reasons, the Image Optimization API using the default [loader](#loader) will  *not*  forward headers when fetching the `src` image.\n> If the `src` image requires authentication, consider using the [unoptimized](#unoptimized) property to disable Image Optimization.\n\n\n\n\n###### `alt`\n\n\n\n\nThe `alt` property is used to describe the image for screen readers and search engines. It is also the fallback text if images have been disabled or an error occurs while loading the image.\n\n\n\n\nIt should contain text that could replace the image [without changing the meaning of the page](https://html.spec.whatwg.org/multipage/images.html#general-guidelines). It is not meant to supplement the image and should not repeat information that is already provided in the captions above or below the image.\n\n\n\n\nIf the image is [purely decorative](https://html.spec.whatwg.org/multipage/images.html#a-purely-decorative-image-that-doesn't-add-any-information) or [not intended for the user](https://html.spec.whatwg.org/multipage/images.html#an-image-not-intended-for-the-user), the `alt` property should be an empty string (`alt=\"\"`).\n\n\n\n\n> Learn more about [image accessibility guidelines](https://html.spec.whatwg.org/multipage/images.html#alt).\n\n\n\n\n###### `width` and `height`\n\n\n\n\nThe `width` and `height` properties represent the [intrinsic](https://developer.mozilla.org/en-US/docs/Glossary/Intrinsic_Size) image size in pixels. This property is used to infer the correct  **aspect ratio**  used by browsers to reserve space for the image and avoid layout shift during loading. It does not determine the  *rendered size*  of the image, which is controlled by CSS.\n\n\n\n\n\nYou  **must**  set both `width` and `height` properties unless:\n\n\n\n\n\n\n- The image is statically imported.\n\n- The image has the [`fill` property](#fill)\n\n\n\n\n\nIf the height and width are unknown, we recommend using the [`fill` property](#fill).\n\n\n\n\n###### `fill`\n\n\n\n\nA boolean that causes the image to expand to the size of the parent element.\n\n\n\n\n\n **Positioning** :\n\n\n\n\n\n\n- The parent element  **must**  assign `position: \"relative\"`, `\"fixed\"`, `\"absolute\"`.\n\n- By default, the `<img>` element uses `position: \"absolute\"`.\n\n\n\n\n\n **Object Fit** :\n\n\n\n\nIf no styles are applied to the image, the image will stretch to fit the container. You can use `objectFit` to control cropping and scaling.\n\n\n\n\n\n\n- `\"contain\"`: The image will be scaled down to fit the container and preserve aspect ratio.\n\n- `\"cover\"`: The image will fill the container and be cropped.\n\n\n\n\n\n> Learn more about [`position`](https://developer.mozilla.org/en-US/docs/Web/CSS/position) and [`object-fit`](https://developer.mozilla.org/docs/Web/CSS/object-fit).\n\n\n\n\n###### `loader`\n\n\n\n\nA custom function used to generate the image URL. The function receives the following parameters, and returns a URL string for the image:\n\n\n\n\n\n\n- [`src`](#src)\n\n- [`width`](#width-and-height)\n\n- [`quality`](#quality)\n\n\n\n\n\n> **Good to know** : Using props like `onLoad`, which accept a function, requires using [Client Components](https://react.dev/reference/rsc/use-client) to serialize the provided function.\n\n\n \n\n\nAlternatively, you can use the [loaderFile](#loaderfile) configuration in `next.config.js` to configure every instance of `next/image` in your application, without passing a prop.\n\n\n\n\n###### `sizes`\n\n\n\n\nDefine the sizes of the image at different breakpoints. Used by the browser to choose the most appropriate size from the generated `srcset`.\n\n\n\n\n\n`sizes` should be used when:\n\n\n\n\n\n\n- The image is using the [`fill`](#fill) prop\n\n- CSS is used to make the image responsive\n\n\n\n\n\nIf `sizes` is missing, the browser assumes the image will be as wide as the viewport (`100vw`). This can cause unnecessarily large images to be downloaded.\n\n\n\n\nIn addition, `sizes` affects how `srcset` is generated:\n\n\n\n\n\n\n- Without `sizes`: Next.js generates a limited `srcset` (e.g. 1x, 2x), suitable for fixed-size images.\n\n- With `sizes`: Next.js generates a full `srcset` (e.g. 640w, 750w, etc.), optimized for responsive layouts.\n\n\n\n\n\n> Learn more about `srcset` and `sizes` on [web.dev](https://web.dev/learn/design/responsive-images/#sizes) and [mdn](https://developer.mozilla.org/docs/Web/HTML/Element/img#sizes).\n\n\n\n\n###### `quality`\n\n\n\n\nAn integer between `1` and `100` that sets the quality of the optimized image. Higher values increase file size and visual fidelity. Lower values reduce file size but may affect sharpness.\n\n\n\n\n\nIf you’ve configured [qualities](#qualities) in `next.config.js`, the value must match one of the allowed entries.\n\n\n\n\n> **Good to know** : If the original image is already low quality, setting a high quality value will increase the file size without improving appearance.\n\n\n\n\n###### `style`\n\n\n\n\nAllows passing CSS styles to the underlying image element.\n\n\n\n\n\n> **Good to know** : If you’re using the `style` prop to set a custom width, be sure to also set `height: 'auto'` to preserve the image’s aspect ratio.\n\n\n\n\n###### `preload`\n\n\n\n\nA boolean that indicates if the image should be preloaded.\n\n\n\n\n\n\n\n- `true`: [Preloads](https://web.dev/preload-responsive-images/) the image by inserting a `<link>` in the `<head>`.\n\n- `false`: Does not preload the image.\n\n\n\n\n\n **When to use it:** \n\n\n\n\n\n\n- The image is the [Largest Contentful Paint (LCP)](https://nextjs.org/learn/seo/web-performance/lcp) element.\n\n- The image is above the fold, typically the hero image.\n\n- You want to begin loading the image in the `<head>`, before its discovered later in the `<body>`.\n\n\n\n\n\n **When not to use it:** \n\n\n\n\n\n\n- When you have multiple images that could be considered the [Largest Contentful Paint (LCP)](https://nextjs.org/learn/seo/web-performance/lcp) element depending on the viewport.\n\n- When the `loading` property is used.\n\n- When the `fetchPriority` property is used.\n\n\n\n\n\nIn most cases, you should use `loading=\"eager\"` or `fetchPriority=\"high\"` instead of `preload`.\n\n\n\n\n###### `priority`\n\n\n\n\nStarting with Next.js 16, the `priority` property has been deprecated in favor of the [`preload`](#preload) property in order to make the behavior clear.\n\n\n\n\n###### `loading`\n\n\n\n\nControls when the image should start loading.\n\n\n\n\n\n\n\n- `lazy`: Defer loading the image until it reaches a calculated distance from the viewport.\n\n- `eager`: Load the image immediately, regardless of its position in the page.\n\n\n\n\n\nUse `eager` only when you want to ensure the image is loaded immediately.\n\n\n\n\n> Learn more about the [`loading` attribute](https://developer.mozilla.org/docs/Web/HTML/Element/img#loading).\n\n\n\n\n###### `placeholder`\n\n\n\n\nSpecifies a placeholder to use while the image is loading, improving the perceived loading performance.\n\n\n\n\n\n\n\n- `empty`: No placeholder while the image is loading.\n\n- `blur`: Use a blurred version of the image as a placeholder. Must be used with the [`blurDataURL`](#blurdataurl) property.\n\n- `data:image/...`: Uses the [Data URL](https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) as the placeholder.\n\n\n\n\n\n **Examples:** \n\n\n\n\n\n\n- [`blur` placeholder](https://image-component.nextjs.gallery/placeholder)\n\n- [Shimmer effect with data URL `placeholder` prop](https://image-component.nextjs.gallery/shimmer)\n\n- [Color effect with `blurDataURL` prop](https://image-component.nextjs.gallery/color)\n\n\n\n\n\n> Learn more about the [`placeholder` attribute](https://developer.mozilla.org/docs/Web/HTML/Element/img#placeholder).\n\n\n\n\n###### `blurDataURL`\n\n\n\n\nA [Data URL](https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) to\nbe used as a placeholder image before the image successfully loads. Can be automatically set or used with the [`placeholder=\"blur\"`](#placeholder) property.\n\n\n\n\n\nThe image is automatically enlarged and blurred, so a very small image (10px or less) is recommended.\n\n\n\n\n **Automatic** \n\n\n\n\nIf `src` is a static import of a `jpg`, `png`, `webp`, or `avif` file, `blurDataURL` is added automatically—unless the image is animated.\n\n\n\n\n **Manually set** \n\n\n\n\nIf the image is dynamic or remote, you must provide `blurDataURL` yourself. To generate one, you can use:\n\n\n\n\n\n\n- [A online tool like png-pixel.com](https://png-pixel.com)\n\n- [A library like Plaiceholder](https://github.com/joe-bell/plaiceholder)\n\n\n\n\n\nA large blurDataURL may hurt performance. Keep it small and simple.\n\n\n\n\n **Examples:** \n\n\n\n\n\n\n- [Default `blurDataURL` prop](https://image-component.nextjs.gallery/placeholder)\n\n- [Color effect with `blurDataURL` prop](https://image-component.nextjs.gallery/color)\n\n\n\n\n\n###### `onLoad`\n\n\n\n\nA callback function that is invoked once the image is completely loaded and the [placeholder](#placeholder) has been removed.\n\n\n\n\n\nThe callback function will be called with one argument, the event which has a `target` that references the underlying `<img>` element.\n\n\n\n\n> **Good to know** : Using props like `onLoad`, which accept a function, requires using [Client Components](https://react.dev/reference/rsc/use-client) to serialize the provided function.\n\n\n\n\n###### `onError`\n\n\n\n\nA callback function that is invoked if the image fails to load.\n\n\n\n\n\n> **Good to know** : Using props like `onError`, which accept a function, requires using [Client Components](https://react.dev/reference/rsc/use-client) to serialize the provided function.\n\n\n\n\n###### `unoptimized`\n\n\n\n\nA boolean that indicates if the image should be optimized. This is useful for images that do not benefit from optimization such as small images (less than 1KB), vector images (SVG), or animated images (GIF).\n\n\n\n\n\n\n\n- `true`: The source image will be served as-is from the `src` instead of changing quality, size, or format.\n\n- `false`: The source image will be optimized.\n\n\n\n\n\nSince Next.js 12.3.0, this prop can be assigned to all images by updating `next.config.js` with the following configuration:\n\n\nnext.config.js\n\n\n###### `overrideSrc`\n\n\n\n\nWhen providing the `src` prop to the `<Image>` component, both the `srcset` and `src` attributes are generated automatically for the resulting `<img>`.\n\n\ninput.js\noutput.html\n\n\nIn some cases, it is not desirable to have the `src` attribute generated and you may wish to override it using the `overrideSrc` prop.\n\n\n\n\nFor example, when upgrading an existing website from `<img>` to `<Image>`, you may wish to maintain the same `src` attribute for SEO purposes such as image ranking or avoiding recrawl.\n\n\ninput.js\noutput.html\n\n\n###### `decoding`\n\n\n\n\nA hint to the browser indicating if it should wait for the image to be decoded before presenting other content updates or not.\n\n\n\n\n\n\n\n- `async`: Asynchronously decode the image and allow other content to be rendered before it completes.\n\n- `sync`: Synchronously decode the image for atomic presentation with other content.\n\n- `auto`: No preference. The browser chooses the best approach.\n\n\n\n\n\n> Learn more about the [`decoding` attribute](https://developer.mozilla.org/docs/Web/HTML/Element/img#decoding).\n\n\n\n\n###### Other Props\n\n\n\n\nOther properties on the `<Image />` component will be passed to the underlying `img` element with the exception of the following:\n\n\n\n\n\n\n- `srcSet`: Use [Device Sizes](#devicesizes) instead.\n\n\n\n\n\n###### Deprecated props\n\n\n\n\n###### `onLoadingComplete`\n\n\n\n\n> **Warning** : Deprecated in Next.js 14, use [`onLoad`](#onload) instead.\n\n\n\n\nA callback function that is invoked once the image is completely loaded and the [placeholder](#placeholder) has been removed.\n\n\n\n\nThe callback function will be called with one argument, a reference to the underlying `<img>` element.\n\n\n\n \n\n\n> **Good to know** : Using props like `onLoadingComplete`, which accept a function, requires using [Client Components](https://react.dev/reference/rsc/use-client) to serialize the provided function.\n\n\n\n\n###### Configuration options\n\n\n\n\nYou can configure the Image Component in `next.config.js`. The following options are available:\n\n\n\n\n###### `localPatterns`\n\n\n\n\nUse `localPatterns` in your `next.config.js` file to allow images from specific local paths to be optimized and block all others.\n\n\nnext.config.js\n\n\nThe example above will ensure the `src` property of `next/image` must start with `/assets/images/` and must not have a query string. Attempting to optimize any other path will respond with `400` Bad Request error.\n\n\n\n\n> **Good to know** : Omitting the `search` property allows all search parameters which could allow malicious actors to optimize URLs you did not intend. Try using a specific value like `search: '?v=2'` to ensure an exact match.\n\n\n\n\n###### `remotePatterns`\n\n\n\n\nUse `remotePatterns` in your `next.config.js` file to allow images from specific external paths and block all others. This ensures that only external images from your account can be served.\n\n\nnext.config.js\n\n\nYou can also configure `remotePatterns` using the object:\n\n\nnext.config.js\n\n\nThe example above will ensure the `src` property of `next/image` must start with `https://example.com/account123/` and must not have a query string. Any other protocol, hostname, port, or unmatched path will respond with `400` Bad Request.\n\n\n\n\n **Wildcard Patterns:** \n\n\n\n\nWildcard patterns can be used for both `pathname` and `hostname` and have the following syntax:\n\n\n\n\n\n\n- `*` match a single path segment or subdomain\n\n- `**` match any number of path segments at the end or subdomains at the beginning. This syntax does not work in the middle of the pattern.\n\n\n\nnext.config.js\n\n\nThis allows subdomains like `image.example.com`. Query strings and custom ports are still blocked.\n\n\n\n\n> **Good to know** : When omitting `protocol`, `port`, `pathname`, or `search` then the wildcard `**` is implied. This is not recommended because it may allow malicious actors to optimize urls you did not intend.\n\n\n\n\n **Query Strings** :\n\n\n\n\nYou can also restrict query strings using the `search` property:\n\n\nnext.config.js\n\n\nThe example above will ensure the `src` property of `next/image` must start with `https://assets.example.com` and must have the exact query string `?v=1727111025337`. Any other protocol or query string will respond with `400` Bad Request.\n\n\n\n\nNote that any allowed `remotePatterns` that respond with a redirect will follow the redirect from the remote image server without validating `remotePatterns` again on the redirect location. You can reduce or disable redirects by configuring [maximumRedirects](#maximumredirects).\n\n\n\n\n###### `loaderFile`\n\n\n\n\n`loaderFiles` allows you to use a custom image optimization service instead of Next.js.\n\n\nnext.config.js\n\n\nThe path must be relative to the project root. The file must export a default function that returns a URL string:\n\n\nmy/image/loader.js\n \n\n\n **Example:** \n\n\n\n\n\n\n- [Custom Image Loader Configuration](/docs/app/api-reference/config/next-config-js/images#example-loader-configuration)\n\n\n\n\n\n> Alternatively, you can use the [`loader` prop](#loader) to configure each instance of `next/image`.\n\n\n\n\n###### `path`\n\n\n\n\nIf you want to change or prefix the default path for the Image Optimization API, you can do so with the `path` property. The default value for `path` is `/_next/image`.\n\n\nnext.config.js\n\n\n###### `deviceSizes`\n\n\n\n\n`deviceSizes` allows you to specify a list of device width breakpoints. These widths are used when the `next/image` component uses [`sizes`](#sizes) prop to ensure the correct image is served for the user's device.\n\n\n\n\nIf no configuration is provided, the default below is used:\n\n\nnext.config.js\n\n\n###### `imageSizes`\n\n\n\n\n`imageSizes` allows you to specify a list of image widths. These widths are concatenated with the array of [device sizes](#devicesizes) to form the full array of sizes used to generate image [srcset](https://developer.mozilla.org/docs/Web/API/HTMLImageElement/srcset).\n\n\n\n\nIf no configuration is provided, the default below is used:\n\n\nnext.config.js\n\n\n`imageSizes` is only used for images which provide a [`sizes`](#sizes) prop, which indicates that the image is less than the full width of the screen. Therefore, the sizes in `imageSizes` should all be smaller than the smallest size in `deviceSizes`.\n\n\n\n\n###### `qualities`\n\n\n\n\n`qualities` allows you to specify a list of image quality values.\n\n\n\n\nIf not configuration is provided, the default below is used:\n\n\nnext.config.js\n\n\n> **Good to know** : This field is required starting with Next.js 16 because unrestricted access could allow malicious actors to optimize more qualities than you intended.\n\n\n\n\nYou can add more image qualities to the allowlist, such as the following:\n\n\nnext.config.js\n\n\nIn the example above, only four qualities are allowed: 25, 50, 75, and 100.\n\n\n\n\nIf the [`quality`](#quality) prop does not match a value in this array, the closest allowed value will be used.\n\n\n\n\nIf the REST API is visited directly with a quality that does not match a value in this array, the server will return a 400 Bad Request response.\n\n\n\n\n###### `formats`\n\n\n\n\n`formats` allows you to specify a list of image formats to be used.\n\n\nnext.config.js\n\n\nNext.js automatically detects the browser's supported image formats via the request's `Accept` header in order to determine the best output format.\n\n\n\n\nIf the `Accept` header matches more than one of the configured formats, the first match in the array is used. Therefore, the array order matters. If there is no match (or the source image is animated), it will use the original image's format.\n\n\n\n\nYou can enable AVIF support, which will fallback to the original format of the src image if the browser [does not support AVIF](https://caniuse.com/avif):\n\n\nnext.config.js\n\n\nYou can also enable both AVIF and WebP formats together. AVIF will be preferred for browsers that support it, with WebP as a fallback:\n\n\nnext.config.js\n\n\n> **Good to know** :\n> \n> \n> \n> \n> \n> \n> - We still recommend using WebP for most use cases.\n> \n> - AVIF generally takes 50% longer to encode but it compresses 20% smaller compared to WebP. This means that the first time an image is requested, it will typically be slower, but subsequent requests that are cached will be faster.\n> \n> - When using multiple formats, Next.js will cache each format separately. This means increased storage requirements compared to using a single format, as both AVIF and WebP versions of images will be stored for different browser support.\n> \n> - If you self-host with a Proxy/CDN in front of Next.js, you must configure the Proxy to forward the `Accept` header.\n\n\n\n\n###### `minimumCacheTTL`\n\n\n\n\n`minimumCacheTTL` allows you to configure the Time to Live (TTL) in seconds for cached optimized images. In many cases, it's better to use a [Static Image Import](/docs/app/getting-started/images#local-images) which will automatically hash the file contents and cache the image forever with a `Cache-Control` header of `immutable`.\n\n\n\n\nIf no configuration is provided, the default below is used.\n\n\nnext.config.js\n\n\nYou can increase the TTL to reduce the number of revalidations and potentially lower cost:\n\n\nnext.config.js\n\n\nThe expiration (or rather Max Age) of the optimized image is defined by either the `minimumCacheTTL` or the upstream image `Cache-Control` header, whichever is larger.\n\n\n\n\nIf you need to change the caching behavior per image, you can configure [`headers`](/docs/app/api-reference/config/next-config-js/headers) to set the `Cache-Control` header on the upstream image (e.g. `/some-asset.jpg`, not `/_next/image` itself).\n\n\n\n\nThere is no mechanism to invalidate the cache at this time, so its best to keep `minimumCacheTTL` low. Otherwise you may need to manually change the [`src`](#src) prop or delete the cached file `<distDir>/cache/images`.\n\n\n\n\n###### `disableStaticImages`\n\n\n\n\n`disableStaticImages` allows you to disable static image imports.\n\n\n\n\nThe default behavior allows you to import static files such as `import icon from './icon.png'` and then pass that to the `src` property. In some cases, you may wish to disable this feature if it conflicts with other plugins that expect the import to behave differently.\n\n\n\n\nYou can disable static image imports inside your `next.config.js`:\n\n\nnext.config.js\n\n\n###### `maximumRedirects`\n\n\n\n\nThe default image optimization loader will follow HTTP redirects when fetching remote images up to 3 times.\n\n\nnext.config.js\n\n\nFor your convenience, these redirects do not need to satisfy [remotePatterns](#remotepatterns).\n\n\n\n\nYou can configure the number of redirects to follow when fetching remote images. Setting the value to `0` will disable following redirects.\n\n\nnext.config.js\n\n\n###### `maximumDiskCacheSize`\n\n\n\n\nThe default image optimization loader will write optimized images to disk so subsequent requests can be served faster from the disk cache.\n\n\n\n\nYou can configure the maximum disk cache size in bytes, for example 500 MB:\n\n\nnext.config.js\n\n\nYou can also disable the disk cache entirely by setting the value to `0`.\n\n\nnext.config.js\n\n\nIf no value is configured, the default behavior is to check the current available disk space once during startup and use 50%.\n\n\n\n\nWhen the disk cache exceeds the configured size, the least recently used optimized images will be deleted until the cache is under the limit again.\n\n\n\n\nAlternatively, you can implement your own cache handler using [`cacheHandler`](/docs/app/api-reference/config/next-config-js/incrementalCacheHandlerPath) which will ignore the `maximumDiskCacheSize` configuration.\n\n\n\n\n###### `maximumResponseBody`\n\n\n\n\nThe default image optimization loader will fetch source images up to 50 MB in size.\n\n\nnext.config.js\n\n\nIf you know all your source images are small, you can protect memory constrained servers by reducing this to a smaller value such as 5 MB.\n\n\nnext.config.js\n\n\n###### `dangerouslyAllowLocalIP`\n\n\n\n\nIn rare cases when self-hosting Next.js on a private network, you may want to allow optimizing images from local IP addresses on the same network. This is not recommended for most users because it could allow malicious users to access content on your internal network.\n\n\n\n\nBy default, the value is false.\n\n\nnext.config.js\n\n\nIf you need to optimize remote images hosted elsewhere in your local network, you can set the value to true.\n\n\nnext.config.js\n\n\nThis might be necessary when hosting Next.js in a VPC with split-horizon DNS and you receive status 400 Bad Request. Only enable once you understand the SSRF risk.\n\n\n\n\n###### `dangerouslyAllowSVG`\n\n\n\n\n`dangerouslyAllowSVG` allows you to serve SVG images.\n\n\nnext.config.js\n\n\nBy default, Next.js does not optimize SVG images for a few reasons:\n\n\n\n\n\n\n- SVG is a vector format meaning it can be resized losslessly.\n\n- SVG has many of the same features as HTML/CSS, which can lead to vulnerabilities without proper [Content Security Policy (CSP) headers](/docs/app/api-reference/config/next-config-js/headers#content-security-policy).\n\n\n\n\n\nWe recommend using the [`unoptimized`](#unoptimized) prop when the [`src`](#src) prop is known to be SVG. This happens automatically when `src` ends with `\".svg\"`.\n\n\n\n\n\nIn addition, it is strongly recommended to also set `contentDispositionType` to force the browser to download the image, as well as `contentSecurityPolicy` to prevent scripts embedded in the image from executing.\n\n\nnext.config.js\n\n\n###### `contentDispositionType`\n\n\n\n\n`contentDispositionType` allows you to configure the [`Content-Disposition`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#as_a_response_header_for_the_main_body) header.\n\n\nnext.config.js\n\n\n###### `contentSecurityPolicy`\n\n\n\n\n`contentSecurityPolicy` allows you to configure the [`Content-Security-Policy`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP) header for images. This is particularly important when using [`dangerouslyAllowSVG`](#dangerouslyallowsvg) to prevent scripts embedded in the image from executing.\n\n\nnext.config.js\n\n\nBy default, the [loader](#loader) sets the [`Content-Disposition`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#as_a_response_header_for_the_main_body) header to `attachment` for added protection since the API can serve arbitrary remote images.\n\n\n\n\nThe default value is `attachment` which forces the browser to download the image when visiting directly. This is particularly important when [`dangerouslyAllowSVG`](#dangerouslyallowsvg) is true.\n\n\n\n\nYou can optionally configure `inline` to allow the browser to render the image when visiting directly, without downloading it.\n\n\n\n\n###### Deprecated configuration options\n\n\n\n\n###### `domains`\n\n\n\n\n> **Warning** : Deprecated since Next.js 14 in favor of strict [`remotePatterns`](#remotepatterns) in order to protect your application from malicious users.\n\n\n\n\nSimilar to [`remotePatterns`](#remotepatterns), the `domains` configuration can be used to provide a list of allowed hostnames for external images. However, the `domains` configuration does not support wildcard pattern matching and it cannot restrict protocol, port, or pathname.\n\n\n\n\nSince most remote image servers are shared between multiple tenants, it's safer to use `remotePatterns` to ensure only the intended images are optimized.\n\n\n\n\nBelow is an example of the `domains` property in the `next.config.js` file:\n\n\nnext.config.js\n\n\n##### Functions\n\n\n\n\n###### `getImageProps`\n\n\n\n\nThe `getImageProps` function can be used to get the props that would be passed to the underlying `<img>` element, and instead pass them to another component, style, canvas, etc.\n\n\n\n\n\nThis also avoid calling React `useState()` so it can lead to better performance, but it cannot be used with the [`placeholder`](#placeholder) prop because the placeholder will never be removed.\n\n\n\n\n##### Known browser bugs\n\n\n\n\nThis `next/image` component uses browser native [lazy loading](https://caniuse.com/loading-lazy-attr), which may fallback to eager loading for older browsers before Safari 15.4. When using the blur-up placeholder, older browsers before Safari 12 will fallback to empty placeholder. When using styles with `width`/`height` of `auto`, it is possible to cause [Layout Shift](https://web.dev/cls/) on older browsers before Safari 15 that don't [preserve the aspect ratio](https://caniuse.com/mdn-html_elements_img_aspect_ratio_computed_from_attributes). For more details, see [this MDN video](https://www.youtube.com/watch?v=4-d_SoCHeWE).\n\n\n\n\n\n\n- [Safari 15 - 16.3](https://bugs.webkit.org/show_bug.cgi?id=243601) display a gray border while loading. Safari 16.4 [fixed this issue](https://webkit.org/blog/13966/webkit-features-in-safari-16-4/#:~:text=Now%20in%20Safari%2016.4%2C%20a%20gray%20line%20no%20longer%20appears%20to%20mark%20the%20space%20where%20a%20lazy%2Dloaded%20image%20will%20appear%20once%20it%E2%80%99s%20been%20loaded.). Possible solutions: \n\n\n\n\n- Use CSS `@supports (font: -apple-system-body) and (-webkit-appearance: none) { img[loading=\"lazy\"] { clip-path: inset(0.6px) } }`\n\n- Use [`loading=\"eager\"`](#loading) if the image is above the fold\n\n- [Firefox 67+](https://bugzilla.mozilla.org/show_bug.cgi?id=1556156) displays a white background while loading. Possible solutions: \n\n\n\n\n- Enable [AVIF `formats`](#formats)\n\n- Use [`placeholder`](#placeholder)\n\n\n\n\n\n##### Examples\n\n\n\n\n###### Styling images\n\n\n\n\nStyling the Image component is similar to styling a normal `<img>` element, but there are a few guidelines to keep in mind:\n\n\n\n\nUse `className` or `style`, not `styled-jsx`. In most cases, we recommend using the `className` prop. This can be an imported [CSS Module](/docs/app/getting-started/css), a [global stylesheet](/docs/app/getting-started/css#global-css), etc.\n\n\n\n\n\nYou can also use the `style` prop to assign inline styles.\n\n\n\n\n\nWhen using `fill`, the parent element must have `position: relative` or `display: block`. This is necessary for the proper rendering of the image element in that layout mode.\n\n\n\n\n\nYou cannot use [styled-jsx](/docs/app/guides/css-in-js) because it's scoped to the current component (unless you mark the style as `global`).\n\n\n\n\n###### Responsive images with a static export\n\n\n\n\nWhen you import a static image, Next.js automatically sets its width and height based on the file. You can make the image responsive by setting the style:\n\n\n<img src=\"/_next/image?", "code_blocks": [{"language": "python", "code": "import Image from 'next/image'\n \nexport default function Page() {\n  return (\n    <Image\n      src=\"/profile.png\"\n      width={500}\n      height={500}\n      alt=\"Picture of the author\"\n    />\n  )\n}", "filename": ""}, {"language": "text", "code": "<Image src=\"/profile.png\" />", "filename": ""}, {"language": "text", "code": "<Image src=\"https://example.com/profile.png\" />", "filename": ""}, {"language": "python", "code": "import profile from './profile.png'\n \nexport default function Page() {\n  return <Image src={profile} />\n}", "filename": ""}, {"language": "text", "code": "<Image src=\"/profile.png\" width={500} height={500} />", "filename": ""}, {"language": "text", "code": "<Image src=\"/profile.png\" fill={true} />", "filename": ""}, {"language": "python", "code": "'use client'\n \nimport Image from 'next/image'\n \nconst imageLoader = ({ src, width, quality }) => {\n  return `https://example.com/${src}?w=${width}&q=${quality || 75}`\n}\n \nexport default function Page() {\n  return (\n    <Image\n      loader={imageLoader}\n      src=\"me.png\"\n      alt=\"Picture of the author\"\n      width={500}\n      height={500}\n    />\n  )\n}", "filename": ""}, {"language": "python", "code": "import Image from 'next/image'\n \nexport default function Page() {\n  return (\n    <div className=\"grid-element\">\n      <Image\n        fill\n        src=\"/example.png\"\n        sizes=\"(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw\"\n      />\n    </div>\n  )\n}", "filename": ""}, {"language": "scilab", "code": "// Default quality is 75\n<Image quality={75} />", "filename": ""}, {"language": "gdscript", "code": "const imageStyle = {\n  borderRadius: '50%',\n  border: '1px solid #fff',\n  width: '100px',\n  height: 'auto',\n}\n \nexport default function ProfileImage() {\n  return <Image src=\"...\" style={imageStyle} />\n}", "filename": ""}, {"language": "gdscript", "code": "// Default preload is false\n<Image preload={false} />", "filename": ""}, {"language": "gdscript", "code": "// Defaults to lazy\n<Image loading=\"lazy\" />", "filename": ""}, {"language": "scilab", "code": "// defaults to empty\n<Image placeholder=\"empty\" />", "filename": ""}, {"language": "text", "code": "<Image placeholder=\"blur\" blurDataURL=\"...\" />", "filename": ""}, {"language": "text", "code": "<Image onLoad={(e) => console.log(e.target.naturalWidth)} />", "filename": ""}, {"language": "text", "code": "<Image onError={(e) => console.error(e.target.id)} />", "filename": ""}, {"language": "python", "code": "import Image from 'next/image'\n \nconst UnoptimizedImage = (props) => {\n  // Default is false\n  return <Image {...props} unoptimized />\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    unoptimized: true,\n  },\n}", "filename": ""}, {"language": "text", "code": "<Image src=\"/profile.jpg\" />", "filename": ""}, {"language": "scdoc", "code": "<img\n  srcset=\"\n    /_next/image?url=%2Fprofile.jpg&w=640&q=75 1x,\n    /_next/image?url=%2Fprofile.jpg&w=828&q=75 2x\n  \"\n  src=\"/_next/image?url=%2Fprofile.jpg&w=828&q=75\"\n/>", "filename": ""}, {"language": "text", "code": "<Image src=\"/profile.jpg\" overrideSrc=\"/override.jpg\" />", "filename": ""}, {"language": "scdoc", "code": "<img\n  srcset=\"\n    /_next/image?url=%2Fprofile.jpg&w=640&q=75 1x,\n    /_next/image?url=%2Fprofile.jpg&w=828&q=75 2x\n  \"\n  src=\"/override.jpg\"\n/>", "filename": ""}, {"language": "scilab", "code": "// Default is async\n<Image decoding=\"async\" />", "filename": ""}, {"language": "text", "code": "'use client'\n \n<Image onLoadingComplete={(img) => console.log(img.naturalWidth)} />", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    localPatterns: [\n      {\n        pathname: '/assets/images/**',\n        search: '',\n      },\n    ],\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    remotePatterns: [new URL('https://example.com/account123/**')],\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    remotePatterns: [\n      {\n        protocol: 'https',\n        hostname: 'example.com',\n        port: '',\n        pathname: '/account123/**',\n        search: '',\n      },\n    ],\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    remotePatterns: [\n      {\n        protocol: 'https',\n        hostname: '**.example.com',\n        port: '',\n        search: '',\n      },\n    ],\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    remotePatterns: [\n      {\n        protocol: 'https',\n        hostname: 'assets.example.com',\n        search: '?v=1727111025337',\n      },\n    ],\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    loader: 'custom',\n    loaderFile: './my/image/loader.js',\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "'use client'\n \nexport default function myImageLoader({ src, width, quality }) {\n  return `https://example.com/${src}?w=${width}&q=${quality || 75}`\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    path: '/my-prefix/_next/image',\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    imageSizes: [32, 48, 64, 96, 128, 256, 384],\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    qualities: [75],\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    qualities: [25, 50, 75, 100],\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    // Default\n    formats: ['image/webp'],\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    formats: ['image/avif'],\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    formats: ['image/avif', 'image/webp'],\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    minimumCacheTTL: 14400, // 4 hours\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    minimumCacheTTL: 2678400, // 31 days\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    disableStaticImages: true,\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    maximumRedirects: 3,\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    maximumRedirects: 0,\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    maximumDiskCacheSize: 500_000_000,\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    maximumDiskCacheSize: 0,\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    maximumResponseBody: 50_000_000,\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    maximumResponseBody: 5_000_000,\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    dangerouslyAllowLocalIP: false,\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    dangerouslyAllowLocalIP: true,\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    dangerouslyAllowSVG: true,\n  },\n}", "filename": ""}, {"language": "text", "code": "<Image src=\"/my-image.svg\" unoptimized />", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    dangerouslyAllowSVG: true,\n    contentDispositionType: 'attachment',\n    contentSecurityPolicy: \"default-src 'self'; script-src 'none'; sandbox;\",\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    contentDispositionType: 'inline',\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    contentSecurityPolicy: \"default-src 'self'; script-src 'none'; sandbox;\",\n  },\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    domains: ['assets.acme.com'],\n  },\n}", "filename": ""}, {"language": "python", "code": "import { getImageProps } from 'next/image'\n \nconst { props } = getImageProps({\n  src: 'https://example.com/image.jpg',\n  alt: 'A scenic mountain view',\n  width: 1200,\n  height: 800,\n})\n \nfunction ImageWithCaption() {\n  return (\n    <figure>\n      <img {...props} />\n      <figcaption>A scenic mountain view</figcaption>\n    </figure>\n  )\n}", "filename": ""}, {"language": "python", "code": "import styles from './styles.module.css'\n \nexport default function MyImage() {\n  return <Image className={styles.image} src=\"/my-image.png\" alt=\"My Image\" />\n}", "filename": ""}, {"language": "gdscript", "code": "export default function MyImage() {\n  return (\n    <Image style={{ borderRadius: '8px' }} src=\"/my-image.png\" alt=\"My Image\" />\n  )\n}", "filename": ""}, {"language": "xml+django", "code": "<div style={{ position: 'relative' }}>\n  <Image fill src=\"/my-image.png\" alt=\"My Image\" />\n</div>", "filename": ""}, {"language": "python", "code": "import Image from 'next/image'\nimport mountains from '../public/mountains.jpg'\n \nexport default function Responsive() {\n  return (\n    <div style={{ display: 'flex', flexDirection: 'column' }}>\n      <Image\n        alt=\"Mountains\"\n        // Importing an image will\n        // automatically set the width and height\n        src={mountains}\n        sizes=\"100vw\"\n        // Make the image display full width\n        // and preserve its aspect ratio\n        style={{\n          width: '100%',\n          height: 'auto',\n        }}\n      />\n    </div>\n  )\n}", "filename": ""}, {"language": "python", "code": "import Image from 'next/image'\n \nexport default function Page({ photoUrl }) {\n  return (\n    <Image\n      src={photoUrl}\n      alt=\"Picture of the author\"\n      sizes=\"100vw\"\n      style={{\n        width: '100%',\n        height: 'auto',\n      }}\n      width={500}\n      height={300}\n    />\n  )\n}", "filename": ""}, {"language": "python", "code": "import Image from 'next/image'\nimport mountains from '../public/mountains.jpg'\n \nexport default function Fill() {\n  return (\n    <div\n      style={{\n        display: 'grid',\n        gridGap: '8px',\n        gridTemplateColumns: 'repeat(auto-fit, minmax(400px, auto))',\n      }}\n    >\n      <div style={{ position: 'relative', width: '400px' }}>\n        <Image\n          alt=\"Mountains\"\n          src={mountains}\n          fill\n          sizes=\"(min-width: 808px) 50vw, 100vw\"\n          style={{\n            objectFit: 'cover', // cover, contain, none\n          }}\n        />\n      </div>\n      {/* And more images in the grid... */}\n    </div>\n  )\n}", "filename": ""}, {"language": "python", "code": "import Image from 'next/image'\nimport mountains from '../public/mountains.jpg'\n \nexport default function Background() {\n  return (\n    <Image\n      alt=\"Mountains\"\n      src={mountains}\n      placeholder=\"blur\"\n      quality={100}\n      fill\n      sizes=\"100vw\"\n      style={{\n        objectFit: 'cover',\n      }}\n    />\n  )\n}", "filename": ""}, {"language": "python", "code": "import Image from 'next/image'\n \nexport default function Page() {\n  return (\n    <Image\n      src=\"https://s3.amazonaws.com/my-bucket/profile.png\"\n      alt=\"Picture of the author\"\n      width={500}\n      height={500}\n    />\n  )\n}", "filename": ""}, {"language": "gdscript", "code": "module.exports = {\n  images: {\n    remotePatterns: [\n      {\n        protocol: 'https',\n        hostname: 's3.amazonaws.com',\n        port: '',\n        pathname: '/my-bucket/**',\n        search: '',\n      },\n    ],\n  },\n}", "filename": ""}, {"language": "gas", "code": ".imgDark {\n  display: none;\n}\n \n@media (prefers-color-scheme: dark) {\n  .imgLight {\n    display: none;\n  }\n  .imgDark {\n    display: unset;\n  }\n}", "filename": ""}, {"language": "python", "code": "import styles from './theme-image.module.css'\nimport Image, { ImageProps } from 'next/image'\n \ntype Props = Omit<ImageProps, 'src' | 'preload' | 'loading'> & {\n  srcLight: string\n  srcDark: string\n}\n \nconst ThemeImage = (props: Props) => {\n  const { srcLight, srcDark, ...rest } = props\n \n  return (\n    <>\n      <Image {...rest} src={srcLight} className={styles.imgLight} />\n      <Image {...rest} src={srcDark} className={styles.imgDark} />\n    </>\n  )\n}", "filename": ""}, {"language": "python", "code": "import { getImageProps } from 'next/image'\n \nexport default function Home() {\n  const common = { alt: 'Art Direction Example', sizes: '100vw' }\n  const {\n    props: { srcSet: desktop },\n  } = getImageProps({\n    ...common,\n    width: 1440,\n    height: 875,\n    quality: 80,\n    src: '/desktop.jpg',\n  })\n  const {\n    props: { srcSet: mobile, ...rest },\n  } = getImageProps({\n    ...common,\n    width: 750,\n    height: 1334,\n    quality: 70,\n    src: '/mobile.jpg',\n  })\n \n  return (\n    <picture>\n      <source media=\"(min-width: 1000px)\" srcSet={desktop} />\n      <source media=\"(min-width: 500px)\" srcSet={mobile} />\n      <img {...rest} style={{ width: '100%', height: 'auto' }} />\n    </picture>\n  )\n}", "filename": ""}, {"language": "python", "code": "import { getImageProps } from 'next/image'\n \nfunction getBackgroundImage(srcSet = '') {\n  const imageSet = srcSet\n    .split(', ')\n    .map((str) => {\n      const [url, dpi] = str.split(' ')\n      return `url(\"${url}\") ${dpi}`\n    })\n    .join(', ')\n  return `image-set(${imageSet})`\n}\n \nexport default function Home() {\n  const {\n    props: { srcSet },\n  } = getImageProps({ alt: '', width: 128, height: 128, src: '/img.png' })\n  const backgroundImage = getBackgroundImage(srcSet)\n  const style = { height: '100vh', width: '100vw', backgroundImage }\n \n  return (\n    <main style={style}>\n      <h1>Hello World</h1>\n    </main>\n  )\n}", "filename": ""}], "chunk_position": 22, "heading_path": "Components: Image Component | Next.js > Components: Image Component | Next.js", "breadcrumbs": "Components: Image Component | Next.js > Components: Image Component | Next.js > Components: Image Component | Next.js"}, {"id": "a5808d6aaaa28d3a", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "Link Component", "content": "Page: Link Component\nSection: Link Component\n\n`<Link>` is a React component that extends the HTML `<a>` element to provide [prefetching](/docs/app/getting-started/linking-and-navigating#prefetching) and client-side navigation between routes. It…", "code_blocks": [{"language": "tsx", "code": "import Link from 'next/link'\n \nexport default function Page() {\n  return <Link href=\"/dashboard\">Dashboard</Link>\n}", "filename": "app/page.tsx"}], "chunk_position": 23, "heading_path": "Link Component > Link Component", "breadcrumbs": "Link Component > Link Component > Link Component"}, {"id": "d3ee5623c026ae2c", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "Reference", "content": "Page: Link Component\nSection: Reference\n\nThe following props can be passed to the `<Link>` component:\n\n| Prop | Example | Type | Required |\n| --- | --- | --- | --- |\n| [`href`](#href-required) | `href=\"/dashboard\"` | String or Object | Yes…", "code_blocks": [], "chunk_position": 23, "heading_path": "Reference > Reference", "breadcrumbs": "Link Component > Reference > Reference"}, {"id": "aa4b335b9b25e220", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "replace", "content": "Page: Link Component\nSection: replace\n\n**Defaults to `false`.** When `true`, `next/link` will replace the current history state instead of adding a new URL into the [browser's…", "code_blocks": [{"language": "tsx", "code": "import Link from 'next/link'\n \nexport default function Page() {\n  return (\n    <Link href=\"/dashboard\" replace>\n      Dashboard\n    </Link>\n  )\n}", "filename": "app/page.tsx"}], "chunk_position": 23, "heading_path": "replace > replace", "breadcrumbs": "Link Component > replace > replace"}, {"id": "1d37c56e23153d25", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "scroll", "content": "Page: Link Component\nSection: scroll\n\n**Defaults to `true`.** The default scrolling behavior of `<Link>` in Next.js **is to maintain scroll position**, similar to how browsers handle back and forwards navigation. When you navigate to a…", "code_blocks": [{"language": "tsx", "code": "import Link from 'next/link'\n \nexport default function Page() {\n  return (\n    <Link href=\"/dashboard\" scroll={false}>\n      Dashboard\n    </Link>\n  )\n}", "filename": "app/page.tsx"}], "chunk_position": 23, "heading_path": "scroll > scroll", "breadcrumbs": "Link Component > scroll > scroll"}, {"id": "2659582036d9895d", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "prefetch", "content": "Page: Link Component\nSection: prefetch\n\nPrefetching happens when a `<Link />` component enters the user's viewport (initially or through scroll). Next.js prefetches and loads the linked route (denoted by the `href`) and its data in the…", "code_blocks": [{"language": "tsx", "code": "import Link from 'next/link'\n \nexport default function Page() {\n  return (\n    <Link href=\"/dashboard\" prefetch={false}>\n      Dashboard\n    </Link>\n  )\n}", "filename": "app/page.tsx"}], "chunk_position": 23, "heading_path": "prefetch > prefetch", "breadcrumbs": "Link Component > prefetch > prefetch"}, {"id": "46cc6ec820db6c74", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "onNavigate", "content": "Page: Link Component\nSection: onNavigate\n\nAn event handler called during client-side navigation. The handler receives an event object that includes a `preventDefault()` method, allowing you to cancel the navigation if needed.\n\n> **Good to…", "code_blocks": [{"language": "tsx", "code": "import Link from 'next/link'\n \nexport default function Page() {\n  return (\n    <Link\n      href=\"/dashboard\"\n      onNavigate={(e) => {\n        // Only executes during SPA navigation…", "filename": "app/page.tsx"}], "chunk_position": 23, "heading_path": "onNavigate > onNavigate", "breadcrumbs": "Link Component > onNavigate > onNavigate"}, {"id": "6575de20fc9d772a", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "transitionTypes", "content": "Page: Link Component\nSection: transitionTypes\n\nA list of transition types to apply to the navigation. These types are passed to [`React.addTransitionType`](https://react.dev/reference/react/addTransitionType) inside the navigation transition,…", "code_blocks": [{"language": "tsx", "code": "import Link from 'next/link'\n \nexport default function Page() {\n  return (\n    <Link href=\"/about\" transitionTypes={['slide-in']}>\n      About\n    </Link>\n  )\n}", "filename": "app/page.tsx"}], "chunk_position": 23, "heading_path": "transitionTypes > transitionTypes", "breadcrumbs": "Link Component > transitionTypes > transitionTypes"}, {"id": "9ccb9980728ab5fb", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "Examples", "content": "Page: Link Component\nSection: Examples\n\nThe following examples demonstrate how to use the `<Link>` component in different scenarios.", "code_blocks": [], "chunk_position": 23, "heading_path": "Examples > Examples", "breadcrumbs": "Link Component > Examples > Examples"}, {"id": "75960b948fce3802", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "Linking to dynamic route segments", "content": "Page: Link Component\nSection: Linking to dynamic route segments\n\nWhen linking to [dynamic segments](/docs/app/api-reference/file-conventions/dynamic-routes), you can use [template literals and…", "code_blocks": [{"language": "tsx", "code": "import Link from 'next/link'\n \ninterface Post {\n  id: number\n  title: string\n  slug: string\n}\n \nexport default function PostList({ posts }: { posts: Post[] }) {\n  return (\n    <ul>…", "filename": "app/blog/post-list.tsx"}], "chunk_position": 23, "heading_path": "Linking to dynamic route segments > Linking to dynamic route segments", "breadcrumbs": "Link Component > Linking to dynamic route segments > Linking to dynamic route segments"}, {"id": "e315ae8fb28509e7", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "Checking active links", "content": "Page: Link Component\nSection: Checking active links\n\nYou can use [`usePathname()`](/docs/app/api-reference/functions/use-pathname) to check if a link is active. For example, to add a class to the active link, you can check if the current `pathname`…", "code_blocks": [{"language": "tsx", "code": "'use client'\n \nimport { usePathname } from 'next/navigation'\nimport Link from 'next/link'\n \nexport function Links() {\n  const pathname = usePathname()\n \n  return (\n    <nav>\n      <Link…", "filename": "app/ui/nav-links.tsx"}], "chunk_position": 23, "heading_path": "Checking active links > Checking active links", "breadcrumbs": "Link Component > Checking active links > Checking active links"}, {"id": "a33b50746833ec50", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "Scrolling to an `id`", "content": "Page: Link Component\nSection: Scrolling to an `id`\n\nIf you'd like to scroll to a specific `id` on navigation, you can append your URL with a `#` hash link or just pass a hash link to the `href` prop. This is possible since `<Link>` renders to an `<a>`…", "code_blocks": [{"language": "jsx", "code": "<Link href=\"/dashboard#settings\">Settings</Link>\n \n// Output\n<a href=\"/dashboard#settings\">Settings</a>", "filename": ""}], "chunk_position": 23, "heading_path": "Scrolling to an `id` > Scrolling to an `id`", "breadcrumbs": "Link Component > Scrolling to an `id` > Scrolling to an `id`"}, {"id": "ccaf274a801b5088", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "Replace the URL instead of push", "content": "Page: Link Component\nSection: Replace the URL instead of push\n\nThe default behavior of the `Link` component is to `push` a new URL into the `history` stack. You can use the `replace` prop to prevent adding a new entry, as in the following example:", "code_blocks": [{"language": "js", "code": "import Link from 'next/link'\n \nexport default function Page() {\n  return (\n    <Link href=\"/about\" replace>\n      About us\n    </Link>\n  )\n}", "filename": "app/page.js"}], "chunk_position": 23, "heading_path": "Replace the URL instead of push > Replace the URL instead of push", "breadcrumbs": "Link Component > Replace the URL instead of push > Replace the URL instead of push"}, {"id": "de01024698ac2093", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "Disable scrolling to the top of the page", "content": "Page: Link Component\nSection: Disable scrolling to the top of the page\n\nThe default scrolling behavior of `<Link>` in Next.js  **is to maintain scroll position**, similar to how browsers handle back and forwards navigation. When you navigate to a new…", "code_blocks": [{"language": "tsx", "code": "import Link from 'next/link'\n \nexport default function Page() {\n  return (\n    <Link href=\"/#hashid\" scroll={false}>\n      Disables scrolling to the top\n    </Link>\n  )\n}", "filename": "app/page.tsx"}, {"language": "js", "code": "// useRouter\nimport { useRouter } from 'next/navigation'\n \nconst router = useRouter()\n \nrouter.push('/dashboard', { scroll: false })", "filename": ""}], "chunk_position": 23, "heading_path": "Disable scrolling to the top of the page > Disable scrolling to the top of the page", "breadcrumbs": "Link Component > Disable scrolling to the top of the page > Disable scrolling to the top of the page"}, {"id": "9c008b70d243326e", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "Scroll offset with sticky headers", "content": "Page: Link Component\nSection: Scroll offset with sticky headers\n\nBecause Next.js skips sticky and fixed positioned elements when finding the scroll target, content may end up behind a sticky header after navigation. For example, if your layout has a sticky…", "code_blocks": [{"language": "tsx", "code": "import './globals.css'\n \nexport default function RootLayout({\n  children,\n}: {\n  children: React.ReactNode\n}) {\n  return (\n    <html lang=\"en\">\n      <body>\n        <header className=\"sticky top-0…", "filename": "app/layout.tsx"}, {"language": "css", "code": "html {\n  scroll-padding-top: 64px; /* Match the height of your sticky header */\n}", "filename": "app/globals.css"}], "chunk_position": 23, "heading_path": "Scroll offset with sticky headers > Scroll offset with sticky headers", "breadcrumbs": "Link Component > Scroll offset with sticky headers > Scroll offset with sticky headers"}, {"id": "7645f3a048812ef3", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "Prefetching links in Proxy", "content": "Page: Link Component\nSection: Prefetching links in Proxy\n\nIt's common to use [Proxy](/docs/app/api-reference/file-conventions/proxy) for authentication or other purposes that involve rewriting the user to a different page. In order for the `<Link />`…", "code_blocks": [{"language": "ts", "code": "import { NextResponse } from 'next/server'\n \nexport function proxy(request: Request) {\n  const nextUrl = request.nextUrl\n  if (nextUrl.pathname === '/dashboard') {\n    if (request.cookies.authToken)…", "filename": "proxy.ts"}, {"language": "tsx", "code": "'use client'\n \nimport Link from 'next/link'\nimport useIsAuthed from './hooks/useIsAuthed' // Your auth hook\n \nexport default function Page() {\n  const isAuthed = useIsAuthed()\n  const path = isAuthed…", "filename": "app/page.tsx"}], "chunk_position": 23, "heading_path": "Prefetching links in Proxy > Prefetching links in Proxy", "breadcrumbs": "Link Component > Prefetching links in Proxy > Prefetching links in Proxy"}, {"id": "4ab4cba3b7a1a07e", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "Blocking navigation", "content": "Page: Link Component\nSection: Blocking navigation\n\nYou can use the `onNavigate` prop to block navigation when certain conditions are met, such as when a form has unsaved changes. When you need to block navigation across multiple components in your…", "code_blocks": [{"language": "tsx", "code": "'use client'\n \nimport { createContext, useState, useContext } from 'react'\n \ninterface NavigationBlockerContextType {\n  isBlocked: boolean\n  setIsBlocked: (isBlocked: boolean) => void\n}\n \nexport…", "filename": "app/contexts/navigation-blocker.tsx"}, {"language": "tsx", "code": "'use client'\n \nimport { useNavigationBlocker } from '../contexts/navigation-blocker'\n \nexport default function Form() {\n  const { setIsBlocked } = useNavigationBlocker()\n \n  return (\n    <form…", "filename": "app/components/form.tsx"}, {"language": "tsx", "code": "'use client'\n \nimport Link from 'next/link'\nimport { useNavigationBlocker } from '../contexts/navigation-blocker'\n \ninterface CustomLinkProps extends React.ComponentProps<typeof Link> {\n  children:…", "filename": "app/components/custom-link.tsx"}, {"language": "tsx", "code": "'use client'\n \nimport { CustomLink as Link } from './custom-link'\n \nexport default function Nav() {\n  return (\n    <nav>\n      <Link href=\"/\">Home</Link>\n      <Link href=\"/about\">About</Link>…", "filename": "app/components/nav.tsx"}, {"language": "tsx", "code": "import { NavigationBlockerProvider } from './contexts/navigation-blocker'\n \nexport default function RootLayout({\n  children,\n}: {\n  children: React.ReactNode\n}) {\n  return (\n    <html lang=\"en\">…", "filename": "app/layout.tsx"}, {"language": "tsx", "code": "import Nav from './components/nav'\nimport Form from './components/form'\n \nexport default function Page() {\n  return (\n    <div>\n      <Nav />\n      <main>\n        <h1>Welcome to the Dashboard</h1>…", "filename": "app/page.tsx"}], "chunk_position": 23, "heading_path": "Blocking navigation > Blocking navigation", "breadcrumbs": "Link Component > Blocking navigation > Blocking navigation"}, {"id": "092a47de9149f57f", "url": "https://nextjs.org/docs/app/api-reference/components/link", "page_title": "Link Component", "page_type": "api", "page_summary": "This page documents the Next.js `<Link>` component, a React component that extends the HTML `<a>` element to provide prefetching and client-side navigation between routes. It covers the component's…", "heading": "Version history", "content": "Page: Link Component\nSection: Version history\n\n| Version | Changes |\n| --- | --- |\n| `v16.2.0` | Add `transitionTypes` prop. |\n| `v15.4.0` | Add `auto` as an alias to the default `prefetch` behavior. |\n| `v15.3.0` | Add `onNavigate` API |\n|…", "code_blocks": [], "chunk_position": 23, "heading_path": "Version history > Version history", "breadcrumbs": "Link Component > Version history > Version history"}, {"id": "eb8c77637b5937ff", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "Script Component", "content": "Page: Script Component\nSection: Script Component\n\nThis API reference will help you understand how to use [props](#props) available for the Script Component. For features and usage, please see the [Optimizing Scripts](/docs/app/guides/scripts) page.", "code_blocks": [{"language": "tsx", "code": "import Script from 'next/script'\n \nexport default function Dashboard() {\n  return (\n    <>\n      <Script src=\"https://example.com/script.js\" />\n    </>\n  )\n}", "filename": "app/dashboard/page.tsx"}], "chunk_position": 24, "heading_path": "Script Component > Script Component", "breadcrumbs": "Script Component > Script Component > Script Component"}, {"id": "3cb3bba90861c427", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "Props", "content": "Page: Script Component\nSection: Props\n\nHere's a summary of the props available for the Script Component:\n\n| Prop | Example | Type | Required |\n| --- | --- | --- | --- |\n| `src` | `src=\"http://example.com/script\"` | String | Required…", "code_blocks": [], "chunk_position": 24, "heading_path": "Props > Props", "breadcrumbs": "Script Component > Props > Props"}, {"id": "8fee72d15878090a", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "Required Props", "content": "Page: Script Component\nSection: Required Props\n\nThe `<Script />` component requires the following properties.", "code_blocks": [], "chunk_position": 24, "heading_path": "Required Props > Required Props", "breadcrumbs": "Script Component > Required Props > Required Props"}, {"id": "0dea886f084e8d2a", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "src", "content": "Page: Script Component\nSection: src\n\nA path string specifying the URL of an external script. This can be either an absolute external URL or an internal path. The `src` property is required unless an inline script is used.", "code_blocks": [], "chunk_position": 24, "heading_path": "src > src", "breadcrumbs": "Script Component > src > src"}, {"id": "c564a7e6613cf735", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "Optional Props", "content": "Page: Script Component\nSection: Optional Props\n\nThe `<Script />` component accepts a number of additional properties beyond those which are required.", "code_blocks": [], "chunk_position": 24, "heading_path": "Optional Props > Optional Props", "breadcrumbs": "Script Component > Optional Props > Optional Props"}, {"id": "024a71131fda9b25", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "strategy", "content": "Page: Script Component\nSection: strategy\n\nThe loading strategy of the script. There are four different strategies that can be used:\n\n- `beforeInteractive`: Load before any Next.js code and before any page hydration occurs.\n-…", "code_blocks": [], "chunk_position": 24, "heading_path": "strategy > strategy", "breadcrumbs": "Script Component > strategy > strategy"}, {"id": "7525c0a5144f56e0", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "beforeInteractive", "content": "Page: Script Component\nSection: beforeInteractive\n\nScripts that load with the `beforeInteractive` strategy are injected into the initial HTML from the server, downloaded before any Next.js module, and executed in the order they are placed.\n\nScripts…", "code_blocks": [{"language": "tsx", "code": "import Script from 'next/script'\n \nexport default function RootLayout({\n  children,\n}: {\n  children: React.ReactNode\n}) {\n  return (\n    <html lang=\"en\">\n      <body>\n        {children}…", "filename": "app/layout.tsx"}], "chunk_position": 24, "heading_path": "beforeInteractive > beforeInteractive", "breadcrumbs": "Script Component > beforeInteractive > beforeInteractive"}, {"id": "4c2b34ff32717fba", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "afterInteractive", "content": "Page: Script Component\nSection: afterInteractive\n\nScripts that use the `afterInteractive` strategy are injected into the HTML client-side and will load after some (or all) hydration occurs on the page. **This is the default strategy** of the Script…", "code_blocks": [{"language": "js", "code": "import Script from 'next/script'\n \nexport default function Page() {\n  return (\n    <>\n      <Script src=\"https://example.com/script.js\" strategy=\"afterInteractive\" />\n    </>\n  )\n}", "filename": "app/page.js"}], "chunk_position": 24, "heading_path": "afterInteractive > afterInteractive", "breadcrumbs": "Script Component > afterInteractive > afterInteractive"}, {"id": "6221eb4fc87cbe31", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "lazyOnload", "content": "Page: Script Component\nSection: lazyOnload\n\nScripts that use the `lazyOnload` strategy are injected into the HTML client-side during browser idle time and will load after all resources on the page have been fetched. This strategy should be…", "code_blocks": [{"language": "js", "code": "import Script from 'next/script'\n \nexport default function Page() {\n  return (\n    <>\n      <Script src=\"https://example.com/script.js\" strategy=\"lazyOnload\" />\n    </>\n  )\n}", "filename": "app/page.js"}], "chunk_position": 24, "heading_path": "lazyOnload > lazyOnload", "breadcrumbs": "Script Component > lazyOnload > lazyOnload"}, {"id": "3ed8f7577f9d74d0", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "worker", "content": "Page: Script Component\nSection: worker\n\n> **Warning:** The `worker` strategy is not yet stable and does not yet work with the App Router. Use with caution.\n\nScripts that use the `worker` strategy are off-loaded to a web worker in order to…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  experimental: {\n    nextScriptWorkers: true,\n  },\n}", "filename": "next.config.js"}, {"language": "tsx", "code": "import Script from 'next/script'\n \nexport default function Home() {\n  return (\n    <>\n      <Script src=\"https://example.com/script.js\" strategy=\"worker\" />\n    </>\n  )\n}", "filename": "pages/home.tsx"}], "chunk_position": 24, "heading_path": "worker > worker", "breadcrumbs": "Script Component > worker > worker"}, {"id": "c487ea6db3439978", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "onLoad", "content": "Page: Script Component\nSection: onLoad\n\n> **Warning:** `onLoad` does not yet work with Server Components and can only be used in Client Components. Further, `onLoad` can't be used with `beforeInteractive` – consider using `onReady`…", "code_blocks": [{"language": "tsx", "code": "'use client'\n \nimport Script from 'next/script'\n \nexport default function Page() {\n  return (\n    <>\n      <Script…", "filename": "app/page.tsx"}], "chunk_position": 24, "heading_path": "onLoad > onLoad", "breadcrumbs": "Script Component > onLoad > onLoad"}, {"id": "4b0ce6392a4058d9", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "onReady", "content": "Page: Script Component\nSection: onReady\n\n> **Warning:** `onReady` does not yet work with Server Components and can only be used in Client Components.\n\nSome third-party scripts require users to run JavaScript code after the script has…", "code_blocks": [{"language": "tsx", "code": "'use client'\n \nimport { useRef } from 'react'\nimport Script from 'next/script'\n \nexport default function Page() {\n  const mapRef = useRef()\n \n  return (\n    <>\n      <div ref={mapRef}></div>…", "filename": "app/page.tsx"}], "chunk_position": 24, "heading_path": "onReady > onReady", "breadcrumbs": "Script Component > onReady > onReady"}, {"id": "1aa5fae62ab0669c", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "onError", "content": "Page: Script Component\nSection: onError\n\n> **Warning:** `onError` does not yet work with Server Components and can only be used in Client Components. `onError` cannot be used with the `beforeInteractive` loading strategy.\n\nSometimes it is…", "code_blocks": [{"language": "tsx", "code": "'use client'\n \nimport Script from 'next/script'\n \nexport default function Page() {\n  return (\n    <>\n      <Script\n        src=\"https://example.com/script.js\"\n        onError={(e: Error) => {…", "filename": "app/page.tsx"}], "chunk_position": 24, "heading_path": "onError > onError", "breadcrumbs": "Script Component > onError > onError"}, {"id": "b2253fbb800915bc", "url": "https://nextjs.org/docs/app/api-reference/components/script", "page_title": "Script Component", "page_type": "api", "page_summary": "API reference for the Next.js Script component (next/script), covering its props, loading strategies, event handlers, and version history.", "heading": "Version History", "content": "Page: Script Component\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v13.0.0` | `beforeInteractive` and `afterInteractive` is modified to support `app`. |\n| `v12.2.4` | `onReady` prop added. |\n| `v12.2.2` | Allow `next/script`…", "code_blocks": [], "chunk_position": 24, "heading_path": "Version History > Version History", "breadcrumbs": "Script Component > Version History > Version History"}, {"id": "fe0eb23cf457f371", "url": "https://nextjs.org/docs/app/api-reference/config", "page_title": "Configuration", "page_type": "overview", "page_summary": "Overview page for Next.js configuration options, linking to documentation for next.config.js, TypeScript, and ESLint.", "heading": "Configuration", "content": "Page: Configuration\nSection: Configuration\n\nnext.config.js: Learn how to configure your application with next.config.js.\n\nTypeScript: Next.js provides a TypeScript-first development experience for building your React application.\n\nESLint:…", "code_blocks": [], "chunk_position": 25, "heading_path": "Configuration > Configuration", "breadcrumbs": "Configuration > Configuration > Configuration"}, {"id": "9b44cf886f300ee2", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "ESLint Plugin", "content": "Page: ESLint Plugin\nSection: ESLint Plugin\n\nNext.js provides an ESLint configuration package, [`eslint-config-next`](https://www.npmjs.com/package/eslint-config-next), that makes it easy to catch common issues in your application. It includes…", "code_blocks": [], "chunk_position": 26, "heading_path": "ESLint Plugin > ESLint Plugin", "breadcrumbs": "ESLint Plugin > ESLint Plugin > ESLint Plugin"}, {"id": "30f200520e34c8ba", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "Setup ESLint", "content": "Page: ESLint Plugin\nSection: Setup ESLint\n\nGet linting working quickly with the ESLint CLI (flat config):", "code_blocks": [{"language": "bash", "code": "pnpm add -D eslint eslint-config-next", "filename": ""}, {"language": "js", "code": "import { defineConfig, globalIgnores } from 'eslint/config'\nimport nextVitals from 'eslint-config-next/core-web-vitals'\n\nconst eslintConfig = defineConfig([\n  ...nextVitals,\n  // Override default…", "filename": "eslint.config.mjs"}, {"language": "bash", "code": "pnpm exec eslint .", "filename": ""}], "chunk_position": 26, "heading_path": "Setup ESLint > Setup ESLint", "breadcrumbs": "ESLint Plugin > Setup ESLint > Setup ESLint"}, {"id": "9d35ea57bf43e5d4", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "Reference", "content": "Page: ESLint Plugin\nSection: Reference\n\nThe `eslint-config-next` package includes the `recommended` rule-sets from the following ESLint plugins:\n\n- [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react)\n-…", "code_blocks": [], "chunk_position": 26, "heading_path": "Reference > Reference", "breadcrumbs": "ESLint Plugin > Reference > Reference"}, {"id": "f9a9cfcb4532b51d", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "Rules", "content": "Page: ESLint Plugin\nSection: Rules\n\nThe `@next/eslint-plugin-next` rules included are:\n\n| Enabled in recommended config | Rule | Description |\n| --- | --- | --- |\n|  |…", "code_blocks": [], "chunk_position": 26, "heading_path": "Rules > Rules", "breadcrumbs": "ESLint Plugin > Rules > Rules"}, {"id": "1e892372f71b8faf", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "Specifying a root directory within a monorepo", "content": "Page: ESLint Plugin\nSection: Specifying a root directory within a monorepo\n\nIf you're using `@next/eslint-plugin-next` in a project where Next.js isn't installed in your root directory (such as a monorepo), you can tell `@next/eslint-plugin-next` where to find your Next.js…", "code_blocks": [{"language": "js", "code": "import { defineConfig } from 'eslint/config'\nimport eslintNextPlugin from '@next/eslint-plugin-next'\n\nconst eslintConfig = defineConfig([\n  {\n    files: ['**/*.{js,jsx,ts,tsx}'],\n    plugins: {…", "filename": "eslint.config.mjs"}], "chunk_position": 26, "heading_path": "Specifying a root directory within a monorepo > Specifying a root directory within a monorepo", "breadcrumbs": "ESLint Plugin > Specifying a root directory within a monorepo > Specifying a root directory within a monorepo"}, {"id": "8769501ad43e1852", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "Disabling rules", "content": "Page: ESLint Plugin\nSection: Disabling rules\n\nIf you would like to modify or disable any rules provided by the supported plugins (`react`, `react-hooks`, `next`), you can directly change them using the `rules` property in your…", "code_blocks": [{"language": "js", "code": "import { defineConfig, globalIgnores } from 'eslint/config'\nimport nextVitals from 'eslint-config-next/core-web-vitals'\n\nconst eslintConfig = defineConfig([\n  ...nextVitals,\n  {\n    rules: {…", "filename": "eslint.config.mjs"}], "chunk_position": 26, "heading_path": "Disabling rules > Disabling rules", "breadcrumbs": "ESLint Plugin > Disabling rules > Disabling rules"}, {"id": "7063653d7016a581", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "With Core Web Vitals", "content": "Page: ESLint Plugin\nSection: With Core Web Vitals\n\nEnable the `eslint-config-next/core-web-vitals` configuration in your ESLint config.\n\n`eslint-config-next/core-web-vitals` upgrades certain lint rules in `@next/eslint-plugin-next` from warnings to…", "code_blocks": [{"language": "js", "code": "import { defineConfig, globalIgnores } from 'eslint/config'\nimport nextVitals from 'eslint-config-next/core-web-vitals'\n\nconst eslintConfig = defineConfig([\n  ...nextVitals,\n  // Override default…", "filename": "eslint.config.mjs"}], "chunk_position": 26, "heading_path": "With Core Web Vitals > With Core Web Vitals", "breadcrumbs": "ESLint Plugin > With Core Web Vitals > With Core Web Vitals"}, {"id": "50977d15edf316c4", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "With TypeScript", "content": "Page: ESLint Plugin\nSection: With TypeScript\n\nIn addition to the Next.js ESLint rules, `create-next-app --typescript` will also add TypeScript-specific lint rules with `eslint-config-next/typescript` to your config:\n\nThose rules are based on…", "code_blocks": [{"language": "js", "code": "import { defineConfig, globalIgnores } from 'eslint/config'\nimport nextVitals from 'eslint-config-next/core-web-vitals'\nimport nextTs from 'eslint-config-next/typescript'\n\nconst eslintConfig =…", "filename": "eslint.config.mjs"}], "chunk_position": 26, "heading_path": "With TypeScript > With TypeScript", "breadcrumbs": "ESLint Plugin > With TypeScript > With TypeScript"}, {"id": "25f5f5dd670ed353", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "With Prettier", "content": "Page: ESLint Plugin\nSection: With Prettier\n\nESLint also contains code formatting rules, which can conflict with your existing [Prettier](https://prettier.io/) setup. We recommend including…", "code_blocks": [{"language": "bash", "code": "pnpm add -D eslint-config-prettier", "filename": ""}, {"language": "js", "code": "import { defineConfig, globalIgnores } from 'eslint/config'\nimport nextVitals from 'eslint-config-next/core-web-vitals'\nimport prettier from 'eslint-config-prettier/flat'\n\nconst eslintConfig =…", "filename": "eslint.config.mjs"}], "chunk_position": 26, "heading_path": "With Prettier > With Prettier", "breadcrumbs": "ESLint Plugin > With Prettier > With Prettier"}, {"id": "bf19704b1eb784fd", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "Running lint on staged files", "content": "Page: ESLint Plugin\nSection: Running lint on staged files\n\nIf you would like to use ESLint with [lint-staged](https://github.com/okonet/lint-staged) to run the linter on staged git files, add the following to the `.lintstagedrc.js` file in the root of your…", "code_blocks": [{"language": "js", "code": "const path = require('path')\n\nconst buildEslintCommand = (filenames) =>\n  `eslint --fix ${filenames\n    .map((f) => `\"${path.relative(process.cwd(), f)}\"`)\n    .join(' ')}`\n\nmodule.exports = {…", "filename": ".lintstagedrc.js"}], "chunk_position": 26, "heading_path": "Running lint on staged files > Running lint on staged files", "breadcrumbs": "ESLint Plugin > Running lint on staged files > Running lint on staged files"}, {"id": "2be5016cf86875b7", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "Migrating existing config", "content": "Page: ESLint Plugin\nSection: Migrating existing config\n\nIf you already have ESLint configured in your application, there are two approaches to integrate Next.js linting rules, depending on your setup.", "code_blocks": [], "chunk_position": 26, "heading_path": "Migrating existing config > Migrating existing config", "breadcrumbs": "ESLint Plugin > Migrating existing config > Migrating existing config"}, {"id": "eb05eeee231076a0", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "Using the plugin directly", "content": "Page: ESLint Plugin\nSection: Using the plugin directly\n\nUse `@next/eslint-plugin-next` directly if you have any of the following already configured:\n\n- Conflicting plugins installed separately or through another config (such as `airbnb` or `react-app`):…", "code_blocks": [{"language": "bash", "code": "pnpm add -D @next/eslint-plugin-next", "filename": ""}, {"language": "js", "code": "import { defineConfig } from 'eslint/config'\nimport nextPlugin from '@next/eslint-plugin-next'\n\nconst eslintConfig = defineConfig([\n  // Your other configurations...\n  {\n    files:…", "filename": "eslint.config.mjs"}], "chunk_position": 26, "heading_path": "Using the plugin directly > Using the plugin directly", "breadcrumbs": "ESLint Plugin > Using the plugin directly > Using the plugin directly"}, {"id": "57e5f0d92446a0a1", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "Adding to existing config", "content": "Page: ESLint Plugin\nSection: Adding to existing config\n\nIf you're adding Next.js to an existing ESLint setup, spread the Next.js config into your array:\n\nWhen you spread `...nextConfig`, you're adding multiple config objects that include file patterns,…", "code_blocks": [{"language": "js", "code": "import nextConfig from 'eslint-config-next/core-web-vitals'\n// Your other config imports...\n\nconst eslintConfig = [\n  // Your other configurations...\n  ...nextConfig,\n]\n\nexport default eslintConfig", "filename": "eslint.config.mjs"}], "chunk_position": 26, "heading_path": "Adding to existing config > Adding to existing config", "breadcrumbs": "ESLint Plugin > Adding to existing config > Adding to existing config"}, {"id": "3bd685b6dbc8b554", "url": "https://nextjs.org/docs/app/api-reference/config/eslint", "page_title": "ESLint Plugin", "page_type": "reference", "page_summary": "Explains how to configure ESLint for Next.js using eslint-config-next, including setup, available rules, examples, and migrating existing ESLint configurations.", "heading": "Version History", "content": "Page: ESLint Plugin\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v16.0.0` | `next lint` and the `eslint` next.config.js option were removed in favor of the ESLint CLI. A…", "code_blocks": [], "chunk_position": 26, "heading_path": "Version History > Version History", "breadcrumbs": "ESLint Plugin > Version History > Version History"}, {"id": "06eae06fcb678078", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js", "page_title": "next.config.js", "page_type": "reference", "page_summary": "Overview of Next.js configuration via next.config.js, including setup, ECMAScript modules, function-based configuration, TypeScript support, and a list of all available configuration options.", "heading": "next.config.js", "content": "Page: next.config.js\nSection: next.config.js\n\nNext.js can be configured through a `next.config.js` file in the root of your project directory (for example, by `package.json`) with a default export.", "code_blocks": [{"language": "js", "code": "// @ts-check\n \n/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  /* config options here */\n}\n \nmodule.exports = nextConfig", "filename": "next.config.js"}], "chunk_position": 27, "heading_path": "next.config.js > next.config.js", "breadcrumbs": "next.config.js > next.config.js > next.config.js"}, {"id": "b3dc2a05147c128c", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js", "page_title": "next.config.js", "page_type": "reference", "page_summary": "Overview of Next.js configuration via next.config.js, including setup, ECMAScript modules, function-based configuration, TypeScript support, and a list of all available configuration options.", "heading": "ECMAScript Modules", "content": "Page: next.config.js\nSection: ECMAScript Modules\n\n`next.config.js` is a regular Node.js module, not a JSON file. It gets used by the Next.js server and build phases, and it's not included in the browser build.\n\nIf you need [ECMAScript…", "code_blocks": [{"language": "js", "code": "// @ts-check\n \n/**\n * @type {import('next').NextConfig}\n */\nconst nextConfig = {\n  /* config options here */\n}\n \nexport default nextConfig", "filename": "next.config.mjs"}], "chunk_position": 27, "heading_path": "ECMAScript Modules > ECMAScript Modules", "breadcrumbs": "next.config.js > ECMAScript Modules > ECMAScript Modules"}, {"id": "5f340696f4b57d38", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js", "page_title": "next.config.js", "page_type": "reference", "page_summary": "Overview of Next.js configuration via next.config.js, including setup, ECMAScript modules, function-based configuration, TypeScript support, and a list of all available configuration options.", "heading": "Async Configuration", "content": "Page: next.config.js\nSection: Async Configuration\n\nSince Next.js 12.1.0, you can use an async function:", "code_blocks": [{"language": "js", "code": "// @ts-check\n \nmodule.exports = async (phase, { defaultConfig }) => {\n  /**\n   * @type {import('next').NextConfig}\n   */\n  const nextConfig = {\n    /* config options here */\n  }\n  return nextConfig\n}", "filename": "next.config.js"}], "chunk_position": 27, "heading_path": "Async Configuration > Async Configuration", "breadcrumbs": "next.config.js > Async Configuration > Async Configuration"}, {"id": "8586eacd9c75a7df", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js", "page_title": "next.config.js", "page_type": "reference", "page_summary": "Overview of Next.js configuration via next.config.js, including setup, ECMAScript modules, function-based configuration, TypeScript support, and a list of all available configuration options.", "heading": "Phase", "content": "Page: next.config.js\nSection: Phase\n\n`phase` is the current context in which the configuration is loaded. You can see the [available phases](https://github.com/vercel/next.js/blob/5e6b008b561caf2710ab7be63320a3d549474a5b/packages/next/sh…", "code_blocks": [{"language": "js", "code": "// @ts-check\n \nconst { PHASE_DEVELOPMENT_SERVER } = require('next/constants')\n \nmodule.exports = (phase, { defaultConfig }) => {\n  if (phase === PHASE_DEVELOPMENT_SERVER) {\n    return {\n      /*…", "filename": "next.config.js"}], "chunk_position": 27, "heading_path": "Phase > Phase", "breadcrumbs": "next.config.js > Phase > Phase"}, {"id": "8d9abe3efbd7bbaa", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js", "page_title": "next.config.js", "page_type": "reference", "page_summary": "Overview of Next.js configuration via next.config.js, including setup, ECMAScript modules, function-based configuration, TypeScript support, and a list of all available configuration options.", "heading": "TypeScript", "content": "Page: next.config.js\nSection: TypeScript\n\nIf you are using TypeScript in your project, you can use `next.config.ts` to use TypeScript in your configuration:\n\nThe commented lines are the place where you can put the configs allowed by…", "code_blocks": [{"language": "ts", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  /* config options here */\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 27, "heading_path": "TypeScript > TypeScript", "breadcrumbs": "next.config.js > TypeScript > TypeScript"}, {"id": "28ecc9f34c653616", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js", "page_title": "next.config.js", "page_type": "reference", "page_summary": "Overview of Next.js configuration via next.config.js, including setup, ECMAScript modules, function-based configuration, TypeScript support, and a list of all available configuration options.", "heading": "Unit Testing (experimental)", "content": "Page: next.config.js\nSection: Unit Testing (experimental)\n\nStarting in Next.js 15.1, the `next/experimental/testing/server` package contains utilities to help unit test `next.config.js` files.\n\nThe `unstable_getResponseFromNextConfig` function runs the…", "code_blocks": [{"language": "js", "code": "import {\n  getRedirectUrl,\n  unstable_getResponseFromNextConfig,\n} from 'next/experimental/testing/server'\n \nconst response = await unstable_getResponseFromNextConfig({\n  url:…", "filename": ""}], "chunk_position": 27, "heading_path": "Unit Testing (experimental) > Unit Testing (experimental)", "breadcrumbs": "next.config.js > Unit Testing (experimental) > Unit Testing (experimental)"}, {"id": "34a30198516a4d45", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js", "page_title": "next.config.js", "page_type": "reference", "page_summary": "Overview of Next.js configuration via next.config.js, including setup, ECMAScript modules, function-based configuration, TypeScript support, and a list of all available configuration options.", "heading": "Available configuration options", "content": "Page: next.config.js\nSection: Available configuration options\n\nThis page documents all the available configuration options:\n\n- **adapterPath**: Configure a custom adapter for Next.js to hook into the build process.\n- **allowedDevOrigins**: Use…", "code_blocks": [], "chunk_position": 27, "heading_path": "Available configuration options > Available configuration options", "breadcrumbs": "next.config.js > Available configuration options > Available configuration options"}, {"id": "7929c0933fbccd1d", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "Overview", "content": "Page: adapterPath\nSection: Overview\n\nNext.js provides a built-in adapters API. It allows deployment platforms or build systems to integrate with the Next.js build process. For a full reference implementation, see the…", "code_blocks": [], "chunk_position": 28, "heading_path": "Overview > Overview", "breadcrumbs": "adapterPath > Overview > Overview"}, {"id": "9296240e06136388", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "Configuration", "content": "Page: adapterPath\nSection: Configuration\n\nTo use an adapter, specify the path to your adapter module in `adapterPath`:\n\nAlternatively `NEXT_ADAPTER_PATH` can be set to enable zero-config usage in deployment platforms.", "code_blocks": [{"language": "js", "code": "/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  adapterPath: require.resolve('./my-adapter.js'),\n}\n \nmodule.exports = nextConfig", "filename": ""}], "chunk_position": 28, "heading_path": "Configuration > Configuration", "breadcrumbs": "adapterPath > Configuration > Configuration"}, {"id": "3d6ed07f80d8186a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "Adapters", "content": "Page: adapterPath\nSection: Adapters\n\nFor full adapter implementation details, use the dedicated Adapters section:\n\n- [Configuration](/docs/app/api-reference/adapters/configuration)\n- [Creating an…", "code_blocks": [], "chunk_position": 28, "heading_path": "Adapters > Adapters", "breadcrumbs": "adapterPath > Adapters > Adapters"}, {"id": "9562d5baee5b42aa", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "Creating an Adapter", "content": "Page: adapterPath\nSection: Creating an Adapter\n\nSee [Creating an Adapter](/docs/app/api-reference/adapters/creating-an-adapter).", "code_blocks": [], "chunk_position": 28, "heading_path": "Creating an Adapter > Creating an Adapter", "breadcrumbs": "adapterPath > Creating an Adapter > Creating an Adapter"}, {"id": "4aef2b497921eb31", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "API Reference", "content": "Page: adapterPath\nSection: API Reference\n\nSee [API Reference](/docs/app/api-reference/adapters/api-reference).", "code_blocks": [], "chunk_position": 28, "heading_path": "API Reference > API Reference", "breadcrumbs": "adapterPath > API Reference > API Reference"}, {"id": "27a217bb653f911d", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "Testing Adapters", "content": "Page: adapterPath\nSection: Testing Adapters\n\nSee [Testing Adapters](/docs/app/api-reference/adapters/testing-adapters).", "code_blocks": [], "chunk_position": 28, "heading_path": "Testing Adapters > Testing Adapters", "breadcrumbs": "adapterPath > Testing Adapters > Testing Adapters"}, {"id": "21fb2bf35400c854", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "Routing with `@next/routing`", "content": "Page: adapterPath\nSection: Routing with `@next/routing`\n\nSee [Routing with `@next/routing`](/docs/app/api-reference/adapters/routing-with-next-routing).", "code_blocks": [], "chunk_position": 28, "heading_path": "Routing with `@next/routing` > Routing with `@next/routing`", "breadcrumbs": "adapterPath > Routing with `@next/routing` > Routing with `@next/routing`"}, {"id": "f99631430d715aca", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "Implementing PPR in an Adapter", "content": "Page: adapterPath\nSection: Implementing PPR in an Adapter\n\nSee [Implementing PPR in an Adapter](/docs/app/api-reference/adapters/implementing-ppr-in-an-adapter).", "code_blocks": [], "chunk_position": 28, "heading_path": "Implementing PPR in an Adapter > Implementing PPR in an Adapter", "breadcrumbs": "adapterPath > Implementing PPR in an Adapter > Implementing PPR in an Adapter"}, {"id": "d7de88164d9d7db5", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "Runtime Integration", "content": "Page: adapterPath\nSection: Runtime Integration\n\nSee [Runtime Integration](/docs/app/api-reference/adapters/runtime-integration).", "code_blocks": [], "chunk_position": 28, "heading_path": "Runtime Integration > Runtime Integration", "breadcrumbs": "adapterPath > Runtime Integration > Runtime Integration"}, {"id": "4a72129c8b26eb02", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "Invoking Entrypoints", "content": "Page: adapterPath\nSection: Invoking Entrypoints\n\nSee [Invoking Entrypoints](/docs/app/api-reference/adapters/invoking-entrypoints).", "code_blocks": [], "chunk_position": 28, "heading_path": "Invoking Entrypoints > Invoking Entrypoints", "breadcrumbs": "adapterPath > Invoking Entrypoints > Invoking Entrypoints"}, {"id": "9a68c2b7c654596c", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "Output Types", "content": "Page: adapterPath\nSection: Output Types\n\nSee [Output Types](/docs/app/api-reference/adapters/output-types).", "code_blocks": [], "chunk_position": 28, "heading_path": "Output Types > Output Types", "breadcrumbs": "adapterPath > Output Types > Output Types"}, {"id": "ac098484861134fa", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "Routing Information", "content": "Page: adapterPath\nSection: Routing Information\n\nSee [Routing Information](/docs/app/api-reference/adapters/routing-information).", "code_blocks": [], "chunk_position": 28, "heading_path": "Routing Information > Routing Information", "breadcrumbs": "adapterPath > Routing Information > Routing Information"}, {"id": "a83313ad89048fda", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/adapterPath", "page_title": "adapterPath", "page_type": "api", "page_summary": "Documentation for the Next.js adapterPath configuration option, which allows deployment platforms or build systems to integrate with the Next.js build process via adapters.", "heading": "Use Cases", "content": "Page: adapterPath\nSection: Use Cases\n\nSee [Use Cases](/docs/app/api-reference/adapters/use-cases).", "code_blocks": [], "chunk_position": 28, "heading_path": "Use Cases > Use Cases", "breadcrumbs": "adapterPath > Use Cases > Use Cases"}, {"id": "18641029b988e5f5", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/allowedDevOrigins", "page_title": "allowedDevOrigins", "page_type": "api", "page_summary": "Describes the `allowedDevOrigins` config option in Next.js, which allows additional origins to request the dev server during development.", "heading": "allowedDevOrigins", "content": "Page: allowedDevOrigins\nSection: allowedDevOrigins\n\nNext.js blocks cross-origin requests to dev-only assets and endpoints during development by default to prevent unauthorized access.\n\nTo configure a Next.js application to allow requests from origins…", "code_blocks": [{"language": "", "code": "module.exports = {\n  allowedDevOrigins: ['local-origin.dev', '*.local-origin.dev'],\n}", "filename": "next.config.js"}], "chunk_position": 29, "heading_path": "allowedDevOrigins > allowedDevOrigins", "breadcrumbs": "allowedDevOrigins > allowedDevOrigins > allowedDevOrigins"}, {"id": "7ce543cc7cd99574", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/appDir", "page_title": "appDir", "page_type": "api", "page_summary": "Documents the `appDir` configuration option in next.config.js, which enables the App Router. It is a legacy API, no longer needed as of Next.js 13.4.", "heading": "appDir", "content": "Page: appDir\nSection: appDir\n\nThis is a legacy API and no longer recommended. It's still supported for backward compatibility.\n\nGood to know: This option is no longer needed as of Next.js 13.4. The App Router is now stable.\n\nThe…", "code_blocks": [], "chunk_position": 30, "heading_path": "appDir > appDir", "breadcrumbs": "appDir > appDir > appDir"}, {"id": "4229ecfef8041a24", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix", "page_title": "assetPrefix", "page_type": "api", "page_summary": "Explains how to configure the `assetPrefix` option in `next.config.js` to serve static assets from a CDN.", "heading": "Set up a CDN", "content": "Page: assetPrefix\nSection: Set up a CDN\n\nAttention: Deploying to Vercel automatically configures a global CDN for your Next.js project. You do not need to manually setup an Asset Prefix.\n\nGood to know: Next.js 9.5+ added support for a…", "code_blocks": [{"language": "javascript", "code": "// @ts-check\nimport { PHASE_DEVELOPMENT_SERVER } from 'next/constants'\n \nexport default (phase) => {\n  const isDev = phase === PHASE_DEVELOPMENT_SERVER\n  /**\n   * @type {import('next').NextConfig}…", "filename": "next.config.mjs"}, {"language": "text", "code": "/_next/static/chunks/4b9b41aaa062cbbfeff4add70f256968c51ece5d.4d708494b3aed70c04f0.js", "filename": ""}, {"language": "text", "code": "https://cdn.mydomain.com/_next/static/chunks/4b9b41aaa062cbbfeff4add70f256968c51ece5d.4d708494b3aed70c04f0.js", "filename": ""}], "chunk_position": 31, "heading_path": "Set up a CDN > Set up a CDN", "breadcrumbs": "assetPrefix > Set up a CDN > Set up a CDN"}, {"id": "a27e33a0de24a1bb", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/authInterrupts", "page_title": "authInterrupts", "page_type": "api", "page_summary": "Reference for the experimental authInterrupts option in next.config.js, which enables the forbidden and unauthorized APIs in a Next.js application.", "heading": "authInterrupts", "content": "Page: authInterrupts\nSection: authInterrupts\n\nThis feature is currently available in the canary channel and subject to change. Try it out by [upgrading Next.js](/docs/app/getting-started/upgrading#canary-version), and share your feedback on…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n\nconst nextConfig: NextConfig = {\n  experimental: {\n    authInterrupts: true,\n  },\n}\n\nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 32, "heading_path": "authInterrupts > authInterrupts", "breadcrumbs": "authInterrupts > authInterrupts > authInterrupts"}, {"id": "969be400257480e1", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath", "page_title": "basePath", "page_type": "reference", "page_summary": "Explains how to use the basePath config option in next.config.js to deploy a Next.js application under a sub-path of a domain.", "heading": "basePath", "content": "Page: basePath\nSection: basePath\n\nTo deploy a Next.js application under a sub-path of a domain you can use the `basePath` config option.\n\n`basePath` allows you to set a path prefix for the application. For example, to use `/docs`…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  basePath: '/docs',\n}", "filename": "next.config.js"}], "chunk_position": 33, "heading_path": "basePath > basePath", "breadcrumbs": "basePath > basePath > basePath"}, {"id": "b03286c097db0e86", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath", "page_title": "basePath", "page_type": "reference", "page_summary": "Explains how to use the basePath config option in next.config.js to deploy a Next.js application under a sub-path of a domain.", "heading": "Links", "content": "Page: basePath\nSection: Links\n\nWhen linking to other pages using `next/link` and `next/router` the `basePath` will be automatically applied.\n\nFor example, using `/about` will automatically become `/docs/about` when `basePath` is…", "code_blocks": [{"language": "jsx", "code": "export default function HomePage() {\n  return (\n    <>\n      <Link href=\"/about\">About Page</Link>\n    </>\n  )\n}", "filename": ""}, {"language": "html", "code": "<a href=\"/docs/about\">About Page</a>", "filename": ""}], "chunk_position": 33, "heading_path": "Links > Links", "breadcrumbs": "basePath > Links > Links"}, {"id": "7b9b4e845ba3f5bc", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath", "page_title": "basePath", "page_type": "reference", "page_summary": "Explains how to use the basePath config option in next.config.js to deploy a Next.js application under a sub-path of a domain.", "heading": "Images", "content": "Page: basePath\nSection: Images\n\nWhen using the [`next/image`](/docs/app/api-reference/components/image) component, you will need to add the `basePath` in front of `src`.\n\nFor example, using `/docs/me.png` will properly serve your…", "code_blocks": [{"language": "jsx", "code": "import Image from 'next/image'\n \nfunction Home() {\n  return (\n    <>\n      <h1>My Homepage</h1>\n      <Image\n        src=\"/docs/me.png\"\n        alt=\"Picture of the author\"\n        width={500}…", "filename": ""}], "chunk_position": 33, "heading_path": "Images > Images", "breadcrumbs": "basePath > Images > Images"}, {"id": "e29f01b24e6e2cdc", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheComponents", "page_title": "cacheComponents", "page_type": "api", "page_summary": "This page documents the `cacheComponents` configuration flag in Next.js, which enables component and function-level caching using the `use cache` directive, and implements Partial Prerendering as the…", "heading": "Usage", "content": "Page: cacheComponents\nSection: Usage\n\nCache Components enables component and function-level caching using the [`use cache`](/docs/app/api-reference/directives/use-cache) directive. Data fetching is dynamic by default, and you choose what…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  cacheComponents: true,\n}\n \nexport default nextConfig", "filename": ""}], "chunk_position": 34, "heading_path": "Usage > Usage", "breadcrumbs": "cacheComponents > Usage > Usage"}, {"id": "25f5bbc934acde86", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheComponents", "page_title": "cacheComponents", "page_type": "api", "page_summary": "This page documents the `cacheComponents` configuration flag in Next.js, which enables component and function-level caching using the `use cache` directive, and implements Partial Prerendering as the…", "heading": "Navigation with Activity", "content": "Page: cacheComponents\nSection: Navigation with Activity\n\nWhen `cacheComponents` is enabled, Next.js uses React's [`<Activity>`](https://react.dev/reference/react/Activity) component to preserve component state during client-side navigation.\n\nRather than…", "code_blocks": [], "chunk_position": 34, "heading_path": "Navigation with Activity > Navigation with Activity", "breadcrumbs": "cacheComponents > Navigation with Activity > Navigation with Activity"}, {"id": "e5e55dbcb4c09b57", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheComponents", "page_title": "cacheComponents", "page_type": "api", "page_summary": "This page documents the `cacheComponents` configuration flag in Next.js, which enables component and function-level caching using the `use cache` directive, and implements Partial Prerendering as the…", "heading": "Version History", "content": "Page: cacheComponents\nSection: Version History\n\n| Version | Change |\n| --- | --- |\n| 16.0.0 | `cacheComponents` introduced. This flag controls the `ppr`, `useCache`, and `dynamicIO` flags as a single, unified configuration. |", "code_blocks": [], "chunk_position": 34, "heading_path": "Version History > Version History", "breadcrumbs": "cacheComponents > Version History > Version History"}, {"id": "35b68b1e74309a60", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheComponents", "page_title": "cacheComponents", "page_type": "api", "page_summary": "This page documents the `cacheComponents` configuration flag in Next.js, which enables component and function-level caching using the `use cache` directive, and implements Partial Prerendering as the…", "heading": "Learn more", "content": "Page: cacheComponents\nSection: Learn more\n\n[### Caching\n\nLearn how to cache data and UI in Next.js](/docs/app/getting-started/caching)[### ISR with Cache Components\n\nLearn how to prerender a subset of dynamic routes, serve App Shells for the…", "code_blocks": [], "chunk_position": 34, "heading_path": "Learn more > Learn more", "breadcrumbs": "cacheComponents > Learn more > Learn more"}, {"id": "2a33ba811cf7fb2b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "cacheHandlers", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: cacheHandlers\n\nThe `cacheHandlers` configuration allows you to define custom cache storage implementations for [`'use cache'`](/docs/app/api-reference/directives/use-cache) and [`'use cache:…", "code_blocks": [], "chunk_position": 35, "heading_path": "cacheHandlers > cacheHandlers", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > cacheHandlers > cacheHandlers"}, {"id": "3a40b65ea8decd2a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "When to use custom cache handlers", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: When to use custom cache handlers\n\n**Most applications don't need custom cache handlers.** The default in-memory cache works well in the typical use case.\n\nCustom cache handlers are for advanced scenarios where you need to either…", "code_blocks": [], "chunk_position": 35, "heading_path": "When to use custom cache handlers > When to use custom cache handlers", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > When to use custom cache handlers > When to use custom cache handlers"}, {"id": "11dab1994766cf2a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "Usage", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: Usage\n\nTo configure custom cache handlers:\n\n- Define your cache handler in a separate file, see [examples](#examples) for implementation details.\n- Reference the file path in your Next config file", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  cacheHandlers: {\n    default: require.resolve('./cache-handlers/default-handler.js'),\n    remote:…", "filename": "next.config.ts"}], "chunk_position": 35, "heading_path": "Usage > Usage", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > Usage > Usage"}, {"id": "5199584dc748c29b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "Handler types", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: Handler types\n\n- **`default`**: Used by the `'use cache'` directive\n- **`remote`**: Used by the `'use cache: remote'` directive\n\nIf you don't configure `cacheHandlers`, Next.js uses an in-memory LRU (Least Recently…", "code_blocks": [], "chunk_position": 35, "heading_path": "Handler types > Handler types", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > Handler types > Handler types"}, {"id": "252223411239d5d5", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "API Reference", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: API Reference\n\nA cache handler must implement the [`CacheHandler`](https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/cache-handlers/types.ts) interface with the following methods:", "code_blocks": [], "chunk_position": 35, "heading_path": "API Reference > API Reference", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > API Reference > API Reference"}, {"id": "2c6123b00b5bef45", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "get()", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: get()\n\nRetrieve a cache entry for the given cache key.\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `cacheKey` | `string` | The unique key for the cache entry. |\n| `softTags` | `string[]` |…", "code_blocks": [{"language": "typescript", "code": "get(cacheKey: string, softTags: string[]): Promise<CacheEntry | undefined>", "filename": ""}, {"language": "javascript", "code": "const cacheHandler = {\n  async get(cacheKey, softTags) {\n    const entry = cache.get(cacheKey)\n    if (!entry) return undefined\n \n    // Check if expired\n    const now = Date.now()\n    if (now >…", "filename": ""}], "chunk_position": 35, "heading_path": "get() > get()", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > get() > get()"}, {"id": "05c6ef586b89943c", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "set()", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: set()\n\nStore a cache entry for the given cache key.\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `cacheKey` | `string` | The unique key to store the entry under. |\n| `pendingEntry` |…", "code_blocks": [{"language": "typescript", "code": "set(cacheKey: string, pendingEntry: Promise<CacheEntry>): Promise<void>", "filename": ""}, {"language": "javascript", "code": "const cacheHandler = {\n  async set(cacheKey, pendingEntry) {\n    // Wait for the entry to be ready\n    const entry = await pendingEntry\n \n    // Store in your cache system\n    cache.set(cacheKey,…", "filename": ""}], "chunk_position": 35, "heading_path": "set() > set()", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > set() > set()"}, {"id": "6e55a34de64fcf1b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "refreshTags()", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: refreshTags()\n\nCalled periodically before starting a new request to sync with external tag services.\n\nThis is useful if you're coordinating cache invalidation across multiple instances or services. For in-memory…", "code_blocks": [{"language": "typescript", "code": "refreshTags(): Promise<void>", "filename": ""}, {"language": "javascript", "code": "const cacheHandler = {\n  async refreshTags() {\n    // For in-memory cache, no action needed\n    // For distributed cache, sync tag state from external service\n  },\n}", "filename": ""}], "chunk_position": 35, "heading_path": "refreshTags() > refreshTags()", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > refreshTags() > refreshTags()"}, {"id": "93343082a57899ef", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "getExpiration()", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: getExpiration()\n\nGet the maximum revalidation timestamp for a set of tags.\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `tags` | `string[]` | Array of tags to check expiration for. |\n\nReturns:\n\n- `0` if…", "code_blocks": [{"language": "typescript", "code": "getExpiration(tags: string[]): Promise<number>", "filename": ""}, {"language": "javascript", "code": "const cacheHandler = {\n  async getExpiration(tags) {\n    // Return 0 if not tracking tag revalidation\n    return 0\n \n    // Or return the most recent revalidation timestamp\n    // return…", "filename": ""}], "chunk_position": 35, "heading_path": "getExpiration() > getExpiration()", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > getExpiration() > getExpiration()"}, {"id": "091394408ec704ac", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "updateTags()", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: updateTags()\n\nCalled when tags are revalidated or expired.\n\n| Parameter | Type | Description |\n| --- | --- | --- |\n| `tags` | `string[]` | Array of tags to update. |\n| `durations` | `{ expire?: number }` |…", "code_blocks": [{"language": "typescript", "code": "updateTags(tags: string[], durations?: { expire?: number }): Promise<void>", "filename": ""}, {"language": "javascript", "code": "const cacheHandler = {\n  async updateTags(tags, durations) {\n    // Invalidate all cache entries with matching tags\n    for (const [key, entry] of cache.entries()) {\n      if (entry.tags.some((tag)…", "filename": ""}], "chunk_position": 35, "heading_path": "updateTags() > updateTags()", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > updateTags() > updateTags()"}, {"id": "d1641e9acb413364", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "CacheEntry Type", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: CacheEntry Type\n\nThe [`CacheEntry`](https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/cache-handlers/types.ts) object has the following structure:\n\n| Property | Type | Description |\n| --- |…", "code_blocks": [{"language": "typescript", "code": "interface CacheEntry {\n  value: ReadableStream<Uint8Array>\n  tags: string[]\n  stale: number\n  timestamp: number\n  expire: number\n  revalidate: number\n}", "filename": ""}], "chunk_position": 35, "heading_path": "CacheEntry Type > CacheEntry Type", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > CacheEntry Type > CacheEntry Type"}, {"id": "eaeac149e2088e78", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "Basic in-memory cache handler", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: Basic in-memory cache handler\n\nHere's a minimal implementation using a `Map` for storage. This example demonstrates the core concepts, but for a production-ready implementation with LRU eviction, error handling, and tag…", "code_blocks": [{"language": "javascript", "code": "const cache = new Map()\nconst pendingSets = new Map()\n \nmodule.exports = {\n  async get(cacheKey, softTags) {\n    // Wait for any pending set operation to complete\n    const pendingPromise =…", "filename": "cache-handlers/memory-handler.js"}], "chunk_position": 35, "heading_path": "Basic in-memory cache handler > Basic in-memory cache handler", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > Basic in-memory cache handler > Basic in-memory cache handler"}, {"id": "254f927390792b82", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "External storage pattern", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: External storage pattern\n\nFor durable storage like Redis or a database, you'll need to serialize the cache entries. Here's a simple Redis example:", "code_blocks": [{"language": "javascript", "code": "const { createClient } = require('redis')\n \nconst client = createClient({ url: process.env.REDIS_URL })\nclient.connect()\n \nmodule.exports = {\n  async get(cacheKey, softTags) {\n    // Retrieve from…", "filename": "cache-handlers/redis-handler.js"}], "chunk_position": 35, "heading_path": "External storage pattern > External storage pattern", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > External storage pattern > External storage pattern"}, {"id": "b8aed696e1ba17e7", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "Distributed Tag Coordination", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: Distributed Tag Coordination\n\nWhen running multiple Next.js instances, tag invalidation must be coordinated across instances. The default in-memory handler only tracks tags locally, so calling `revalidateTag()` on one instance…", "code_blocks": [{"language": "javascript", "code": "const { createClient } = require('redis')\n \nconst client = createClient({ url: process.env.REDIS_URL })\nclient.connect()\n \n// Local cache of tag timestamps, synced via refreshTags\nconst…", "filename": "cache-handlers/distributed-tags.js"}], "chunk_position": 35, "heading_path": "Distributed Tag Coordination > Distributed Tag Coordination", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > Distributed Tag Coordination > Distributed Tag Coordination"}, {"id": "cd41ccfec8575d4d", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "Soft Tags", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: Soft Tags\n\nSoft tags are implicit tags that Next.js automatically generates based on the route path. For example, the route `/blog/hello` generates soft tags for `/`, `/blog`, `/blog/hello`, and their…", "code_blocks": [], "chunk_position": 35, "heading_path": "Soft Tags > Soft Tags", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > Soft Tags > Soft Tags"}, {"id": "953f31b52befe401", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "Handling Streams", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: Handling Streams\n\nThe `CacheEntry.value` is a [`ReadableStream<Uint8Array>`](https://developer.mozilla.org/docs/Web/API/ReadableStream). When implementing a cache handler that stores entries externally, keep in…", "code_blocks": [], "chunk_position": 35, "heading_path": "Handling Streams > Handling Streams", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > Handling Streams > Handling Streams"}, {"id": "ee3cbf0cf2c7554c", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "Error Handling", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: Error Handling\n\nCache operations should be implemented defensively:\n\n- **`set()` failure**: the response is still served to the user because `set()` is called asynchronously after the response stream is already…", "code_blocks": [], "chunk_position": 35, "heading_path": "Error Handling > Error Handling", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > Error Handling > Error Handling"}, {"id": "c7635d09d91686a0", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "Platform Support", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: Platform Support\n\n| Deployment Option | Supported |\n| --- | --- |\n| [Node.js server](/docs/app/getting-started/deploying#nodejs-server) | Yes |\n| [Docker container](/docs/app/getting-started/deploying#docker) | Yes…", "code_blocks": [], "chunk_position": 35, "heading_path": "Platform Support > Platform Support", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > Platform Support > Platform Support"}, {"id": "5699aed7d993a5f8", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "Version History", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v16.0.0` | `cacheHandlers` introduced. |", "code_blocks": [], "chunk_position": 35, "heading_path": "Version History > Version History", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > Version History > Version History"}, {"id": "1beff3c3a7a0b665", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheHandlers", "page_title": "next.config.js: cacheHandlers | Next.js", "page_type": "api", "page_summary": "This page documents the `cacheHandlers` configuration in next.config.js, which lets you define custom cache storage implementations for `'use cache'` and `'use cache: remote'`. It covers handler…", "heading": "Related", "content": "Page: next.config.js: cacheHandlers | Next.js\nSection: Related\n\nView related API references.\n\n- [use cache](/docs/app/api-reference/directives/use-cache) — Learn how to use the \"use cache\" directive to cache data in your Next.js application.\n- [use cache:…", "code_blocks": [], "chunk_position": 35, "heading_path": "Related > Related", "breadcrumbs": "next.config.js: cacheHandlers | Next.js > Related > Related"}, {"id": "8cb6c64b3ef34a1b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheLife", "page_title": "next.config.js: cacheLife | Next.js", "page_type": "api", "page_summary": "Reference for the cacheLife option in next.config.js, which lets you define custom cache profiles for use with the cacheLife function and the use cache directive.", "heading": "cacheLife", "content": "Page: next.config.js: cacheLife | Next.js\nSection: cacheLife\n\nThe `cacheLife` option allows you to define **custom cache profiles** when using the [`cacheLife`](/docs/app/api-reference/functions/cacheLife) function inside components or functions, and within the…", "code_blocks": [], "chunk_position": 36, "heading_path": "cacheLife > cacheLife", "breadcrumbs": "next.config.js: cacheLife | Next.js > cacheLife > cacheLife"}, {"id": "d369248a5f196945", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheLife", "page_title": "next.config.js: cacheLife | Next.js", "page_type": "api", "page_summary": "Reference for the cacheLife option in next.config.js, which lets you define custom cache profiles for use with the cacheLife function and the use cache directive.", "heading": "Usage", "content": "Page: next.config.js: cacheLife | Next.js\nSection: Usage\n\nTo define a profile, enable the [`cacheComponents` flag](/docs/app/api-reference/config/next-config-js/cacheComponents) and add the cache profile in the `cacheLife` object in the `next.config.js`…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  cacheComponents: true,\n  cacheLife: {\n    blog: {\n      stale: 3600, // 1 hour\n      revalidate: 900, // 15 minutes…", "filename": "next.config.ts"}, {"language": "typescript", "code": "import { cacheLife } from 'next/cache'\n \nexport async function getCachedData() {\n  'use cache'\n  cacheLife('blog')\n  const data = await fetch('/api/data')\n  return data\n}", "filename": "app/actions.ts"}], "chunk_position": 36, "heading_path": "Usage > Usage", "breadcrumbs": "next.config.js: cacheLife | Next.js > Usage > Usage"}, {"id": "e23c345a33e2977b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheLife", "page_title": "next.config.js: cacheLife | Next.js", "page_type": "api", "page_summary": "Reference for the cacheLife option in next.config.js, which lets you define custom cache profiles for use with the cacheLife function and the use cache directive.", "heading": "Reference", "content": "Page: next.config.js: cacheLife | Next.js\nSection: Reference\n\nThe configuration object has key values with the following format:\n\n| **Property** | **Value** | **Description** | **Requirement** |\n| --- | --- | --- | --- |\n| `stale` | `number` | Duration the…", "code_blocks": [], "chunk_position": 36, "heading_path": "Reference > Reference", "breadcrumbs": "next.config.js: cacheLife | Next.js > Reference > Reference"}, {"id": "fa58ecbe9667affa", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheLife", "page_title": "next.config.js: cacheLife | Next.js", "page_type": "api", "page_summary": "Reference for the cacheLife option in next.config.js, which lets you define custom cache profiles for use with the cacheLife function and the use cache directive.", "heading": "Related", "content": "Page: next.config.js: cacheLife | Next.js\nSection: Related\n\nView related API references.\n\n- [use cache](/docs/app/api-reference/directives/use-cache) — Learn how to use the \"use cache\" directive to cache data in your Next.js application.\n-…", "code_blocks": [], "chunk_position": 36, "heading_path": "Related > Related", "breadcrumbs": "next.config.js: cacheLife | Next.js > Related > Related"}, {"id": "3a384eada381a8b6", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/compress", "page_title": "compress", "page_type": "api", "page_summary": "This page describes the `compress` option in `next.config.js`, which controls gzip compression for rendered content and static files when using `next start` or a custom server.", "heading": "compress", "content": "Page: compress\nSection: compress\n\nBy default, Next.js uses `gzip` to compress rendered content and static files when using `next start` or a custom server. This is an optimization for applications that do not have compression…", "code_blocks": [], "chunk_position": 37, "heading_path": "compress > compress", "breadcrumbs": "compress > compress > compress"}, {"id": "631daca87bb0c94b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/compress", "page_title": "compress", "page_type": "api", "page_summary": "This page describes the `compress` option in `next.config.js`, which controls gzip compression for rendered content and static files when using `next start` or a custom server.", "heading": "Disabling compression", "content": "Page: compress\nSection: Disabling compression\n\nTo disable **compression**, set the `compress` config option to `false`:\n\nWe **do not recommend disabling compression** unless you have compression configured on your server, as compression reduces…", "code_blocks": [{"language": "", "code": "module.exports = {\n  compress: false,\n}", "filename": "next.config.js"}], "chunk_position": 37, "heading_path": "Disabling compression > Disabling compression", "breadcrumbs": "compress > Disabling compression > Disabling compression"}, {"id": "d45ae5f3ea4bdb17", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/crossOrigin", "page_title": "crossOrigin", "page_type": "api", "page_summary": "Use the `crossOrigin` option to add a `crossOrigin` attribute in all `<script>` tags generated by the `next/script` component, and define how cross-origin requests should be handled.", "heading": "crossOrigin", "content": "Page: crossOrigin\nSection: crossOrigin\n\nUse the `crossOrigin` option to add a [`crossOrigin` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) in all `<script>` tags generated by the…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  crossOrigin: 'anonymous',\n}", "filename": ""}], "chunk_position": 38, "heading_path": "crossOrigin > crossOrigin", "breadcrumbs": "crossOrigin > crossOrigin > crossOrigin"}, {"id": "628d3c3d1a3cd259", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/crossOrigin", "page_title": "crossOrigin", "page_type": "api", "page_summary": "Use the `crossOrigin` option to add a `crossOrigin` attribute in all `<script>` tags generated by the `next/script` component, and define how cross-origin requests should be handled.", "heading": "Options", "content": "Page: crossOrigin\nSection: Options\n\n- `'anonymous'`: Adds [`crossOrigin=\"anonymous\"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin#anonymous) attribute.\n\n- `'use-credentials'`: Adds…", "code_blocks": [], "chunk_position": 38, "heading_path": "Options > Options", "breadcrumbs": "crossOrigin > Options > Options"}, {"id": "8fa39dfa0900aa87", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cssChunking", "page_title": "next.config.js: cssChunking", "page_type": "reference", "page_summary": "This page documents the experimental `cssChunking` option in Next.js configuration, which controls how CSS files are split and re-ordered into chunks to improve performance. It covers the available…", "heading": "cssChunking", "content": "Page: next.config.js: cssChunking\nSection: cssChunking\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on GitHub.\n\nCSS Chunking is a strategy used to improve the…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig = {\n  experimental: {\n    cssChunking: true, // default\n  },\n} satisfies NextConfig\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 39, "heading_path": "cssChunking > cssChunking", "breadcrumbs": "next.config.js: cssChunking > cssChunking > cssChunking"}, {"id": "0541b148e07b9e32", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cssChunking", "page_title": "next.config.js: cssChunking", "page_type": "reference", "page_summary": "This page documents the experimental `cssChunking` option in Next.js configuration, which controls how CSS files are split and re-ordered into chunks to improve performance. It covers the available…", "heading": "Options", "content": "Page: next.config.js: cssChunking\nSection: Options\n\n- **`true` (default)** (**webpack and Turbopack**): Next.js will try to merge CSS files whenever possible, determining explicit and implicit dependencies between files from import order to reduce the…", "code_blocks": [], "chunk_position": 39, "heading_path": "Options > Options", "breadcrumbs": "next.config.js: cssChunking > Options > Options"}, {"id": "462c52c04113953e", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cssChunking", "page_title": "next.config.js: cssChunking", "page_type": "reference", "page_summary": "This page documents the experimental `cssChunking` option in Next.js configuration, which controls how CSS files are split and re-ordered into chunks to improve performance. It covers the available…", "heading": "Choosing a strategy", "content": "Page: next.config.js: cssChunking\nSection: Choosing a strategy\n\nFor most applications, the default (`true`) is the right choice in either bundler: it merges CSS to make fewer requests. Reach for another strategy only for a specific reason.\n\nIn Turbopack, that…", "code_blocks": [], "chunk_position": 39, "heading_path": "Choosing a strategy > Choosing a strategy", "breadcrumbs": "next.config.js: cssChunking > Choosing a strategy > Choosing a strategy"}, {"id": "ab96c642f538cc84", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cssChunking", "page_title": "next.config.js: cssChunking", "page_type": "reference", "page_summary": "This page documents the experimental `cssChunking` option in Next.js configuration, which controls how CSS files are split and re-ordered into chunks to improve performance. It covers the available…", "heading": "Debugging what a route actually uses", "content": "Page: next.config.js: cssChunking\nSection: Debugging what a route actually uses\n\nWhile some unused CSS is acceptable, and most apps do not need to change anything, it is worth keeping render-blocking CSS in check. Lighthouse flags this as a **Reduce unused CSS** opportunity with…", "code_blocks": [], "chunk_position": 39, "heading_path": "Debugging what a route actually uses > Debugging what a route actually uses", "breadcrumbs": "next.config.js: cssChunking > Debugging what a route actually uses > Debugging what a route actually uses"}, {"id": "9ad0a6528f278083", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cssChunking", "page_title": "next.config.js: cssChunking", "page_type": "reference", "page_summary": "This page documents the experimental `cssChunking` option in Next.js configuration, which controls how CSS files are split and re-ordered into chunks to improve performance. It covers the available…", "heading": "Balancing requests and grouping", "content": "Page: next.config.js: cssChunking\nSection: Balancing requests and grouping\n\nThe `graph` strategy groups CSS into shared chunks to cut requests. Turn it on with the string form, which uses the default tuning:", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig = {\n  experimental: {\n    cssChunking: 'graph',\n  },\n} satisfies NextConfig\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 39, "heading_path": "Balancing requests and grouping > Balancing requests and grouping", "breadcrumbs": "next.config.js: cssChunking > Balancing requests and grouping > Balancing requests and grouping"}, {"id": "ffa90e7ab445f58c", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cssChunking", "page_title": "next.config.js: cssChunking", "page_type": "reference", "page_summary": "This page documents the experimental `cssChunking` option in Next.js configuration, which controls how CSS files are split and re-ordered into chunks to improve performance. It covers the available…", "heading": "Balancing requests and grouping (continued)", "content": "Page: next.config.js: cssChunking\nSection: Balancing requests and grouping (continued)\n\nTo shift that balance, pass an object instead. Both `requestCost` and `weightDistribution` are optional, so include only the one you want to change:", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig = {\n  experimental: {\n    cssChunking: {\n      type: 'graph',\n      requestCost: 100000,\n      weightDistribution: 0.1,\n    },\n  },\n}…", "filename": "next.config.ts"}], "chunk_position": 39, "heading_path": "Balancing requests and grouping (continued) > Balancing requests and grouping (continued)", "breadcrumbs": "next.config.js: cssChunking > Balancing requests and grouping (continued) > Balancing requests and grouping (continued)"}, {"id": "4dd57998c3dbb9dc", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cssChunking", "page_title": "next.config.js: cssChunking", "page_type": "reference", "page_summary": "This page documents the experimental `cssChunking` option in Next.js configuration, which controls how CSS files are split and re-ordered into chunks to improve performance. It covers the available…", "heading": "Balancing requests and grouping (options)", "content": "Page: next.config.js: cssChunking\nSection: Balancing requests and grouping (options)\n\n- **`requestCost`** (default `20000`): the estimated cost, in bytes, of each additional CSS request. Larger values bias toward fewer, larger shared chunks, and fewer requests overall.\n\n-…", "code_blocks": [], "chunk_position": 39, "heading_path": "Balancing requests and grouping (options) > Balancing requests and grouping (options)", "breadcrumbs": "next.config.js: cssChunking > Balancing requests and grouping (options) > Balancing requests and grouping (options)"}, {"id": "e7ad77fa549a36c1", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cssChunking", "page_title": "next.config.js: cssChunking", "page_type": "reference", "page_summary": "This page documents the experimental `cssChunking` option in Next.js configuration, which controls how CSS files are split and re-ordered into chunks to improve performance. It covers the available…", "heading": "How `graph` decides what to merge", "content": "Page: next.config.js: cssChunking\nSection: How `graph` decides what to merge\n\nMerging CSS into shared chunks is what the default (`true`) already does; `graph` just lets you control where it draws the line between merging and splitting.\n\nTake two routes that share a…", "code_blocks": [], "chunk_position": 39, "heading_path": "How `graph` decides what to merge > How `graph` decides what to merge", "breadcrumbs": "next.config.js: cssChunking > How `graph` decides what to merge > How `graph` decides what to merge"}, {"id": "47714c6b6706aeb8", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/cssChunking", "page_title": "next.config.js: cssChunking", "page_type": "reference", "page_summary": "This page documents the experimental `cssChunking` option in Next.js configuration, which controls how CSS files are split and re-ordered into chunks to improve performance. It covers the available…", "heading": "Graph algorithm overview", "content": "Page: next.config.js: cssChunking\nSection: Graph algorithm overview\n\nAt a high level, the algorithm works with individual CSS files. It starts from the ordered list of CSS each route imports:\n\n```\n/dashboard  → [reset.css, theme.css, layout.css,…", "code_blocks": [], "chunk_position": 39, "heading_path": "Graph algorithm overview > Graph algorithm overview", "breadcrumbs": "next.config.js: cssChunking > Graph algorithm overview > Graph algorithm overview"}, {"id": "95e950bdb4a14596", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/deploymentId", "page_title": "next.config.js: deploymentId", "page_type": "reference", "page_summary": "Documentation for the Next.js `deploymentId` configuration option, which sets a deployment identifier for version skew protection and cache busting during rolling deployments. Covers configuration,…", "heading": "deploymentId", "content": "Page: next.config.js: deploymentId\nSection: deploymentId\n\nThe `deploymentId` option allows you to set an identifier for your deployment. This identifier is used for [version skew](https://nextjs.org/docs/app/guides/self-hosting#version-skew) protection and…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  deploymentId: 'my-deployment-id',\n}", "filename": "next.config.js"}, {"language": "bash", "code": "NEXT_DEPLOYMENT_ID=my-deployment-id next build", "filename": ""}], "chunk_position": 40, "heading_path": "deploymentId > deploymentId", "breadcrumbs": "next.config.js: deploymentId > deploymentId > deploymentId"}, {"id": "03f3032f4ee969d3", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/deploymentId", "page_title": "next.config.js: deploymentId", "page_type": "reference", "page_summary": "Documentation for the Next.js `deploymentId` configuration option, which sets a deployment identifier for version skew protection and cache busting during rolling deployments. Covers configuration,…", "heading": "How it works", "content": "Page: next.config.js: deploymentId\nSection: How it works\n\nWhen a `deploymentId` is configured, Next.js:\n\n- Appends `?dpl=<deploymentId>` to static asset URLs (JavaScript, CSS, images)\n- Adds an `x-deployment-id` header to client-side navigation requests\n-…", "code_blocks": [], "chunk_position": 40, "heading_path": "How it works > How it works", "breadcrumbs": "next.config.js: deploymentId > How it works > How it works"}, {"id": "a8e21d1a095f9e2f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/deploymentId", "page_title": "next.config.js: deploymentId", "page_type": "reference", "page_summary": "Documentation for the Next.js `deploymentId` configuration option, which sets a deployment identifier for version skew protection and cache busting during rolling deployments. Covers configuration,…", "heading": "Rolling deployments", "content": "Page: next.config.js: deploymentId\nSection: Rolling deployments\n\nDuring a rolling deployment, some server instances may be running the new version while others are still running the old version. Without a deployment ID, users might receive a mix of old and new…", "code_blocks": [], "chunk_position": 40, "heading_path": "Rolling deployments > Rolling deployments", "breadcrumbs": "next.config.js: deploymentId > Rolling deployments > Rolling deployments"}, {"id": "9e8e0a644ecaecfc", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/deploymentId", "page_title": "next.config.js: deploymentId", "page_type": "reference", "page_summary": "Documentation for the Next.js `deploymentId` configuration option, which sets a deployment identifier for version skew protection and cache busting during rolling deployments. Covers configuration,…", "heading": "Multi-server environments", "content": "Page: next.config.js: deploymentId\nSection: Multi-server environments\n\nWhen running multiple instances of your Next.js application behind a load balancer, all instances for the same deployment should use the same `deploymentId`.", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  deploymentId: process.env.DEPLOYMENT_VERSION || process.env.GIT_SHA,\n}", "filename": "next.config.js"}], "chunk_position": 40, "heading_path": "Multi-server environments > Multi-server environments", "breadcrumbs": "next.config.js: deploymentId > Multi-server environments > Multi-server environments"}, {"id": "e7ef2e6de049c673", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/deploymentId", "page_title": "next.config.js: deploymentId", "page_type": "reference", "page_summary": "Documentation for the Next.js `deploymentId` configuration option, which sets a deployment identifier for version skew protection and cache busting during rolling deployments. Covers configuration,…", "heading": "Version History", "content": "Page: next.config.js: deploymentId\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v14.1.4` | `deploymentId` stabilized as top-level config option. |\n| `v13.4.10` | `experimental.deploymentId` introduced. |", "code_blocks": [], "chunk_position": 40, "heading_path": "Version History > Version History", "breadcrumbs": "next.config.js: deploymentId > Version History > Version History"}, {"id": "9e109808b461a3dd", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/deploymentId", "page_title": "next.config.js: deploymentId", "page_type": "reference", "page_summary": "Documentation for the Next.js `deploymentId` configuration option, which sets a deployment identifier for version skew protection and cache busting during rolling deployments. Covers configuration,…", "heading": "Related", "content": "Page: next.config.js: deploymentId\nSection: Related\n\n- [Self-Hosting - Version Skew](https://nextjs.org/docs/app/guides/self-hosting#version-skew)\n- [generateBuildId](https://nextjs.org/docs/app/api-reference/config/next-config-js/generateBuildId)", "code_blocks": [], "chunk_position": 40, "heading_path": "Related > Related", "breadcrumbs": "next.config.js: deploymentId > Related > Related"}, {"id": "3d144285a316c87a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/devIndicators", "page_title": "devIndicators", "page_type": "api", "page_summary": "Configuration for the on-screen development indicator in Next.js, allowing you to set its position or hide it entirely.", "heading": "devIndicators", "content": "Page: devIndicators\nSection: devIndicators\n\n`devIndicators` allows you to configure the on-screen indicator that gives context about the current route you're viewing during development. Open `next.config.ts` and set `position` to choose where…", "code_blocks": [{"language": "ts", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  devIndicators: {\n    position: 'bottom-right', // 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'\n  },\n}\n \nexport…", "filename": "next.config.ts"}, {"language": "ts", "code": "const nextConfig: NextConfig = {\n  devIndicators: false,\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 41, "heading_path": "devIndicators > devIndicators", "breadcrumbs": "devIndicators > devIndicators > devIndicators"}, {"id": "728c4958203972f2", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/devIndicators", "page_title": "devIndicators", "page_type": "api", "page_summary": "Configuration for the on-screen development indicator in Next.js, allowing you to set its position or hide it entirely.", "heading": "Indicator not marking a route as static", "content": "Page: devIndicators\nSection: Indicator not marking a route as static\n\nIf you expect a route to be static and the indicator has marked it as dynamic, it's likely the route has opted out of prerendering. You can confirm if a route is…", "code_blocks": [{"language": "text", "code": "Route (app)\n┌ ○ /_not-found\n└ ƒ /products/[id]\n \n○  (Static)   prerendered as static content\nƒ  (Dynamic)  server-rendered on demand", "filename": "Build Output"}], "chunk_position": 41, "heading_path": "Indicator not marking a route as static > Indicator not marking a route as static", "breadcrumbs": "devIndicators > Indicator not marking a route as static > Indicator not marking a route as static"}, {"id": "24b0e0c804b3e373", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/devIndicators", "page_title": "devIndicators", "page_type": "api", "page_summary": "Configuration for the on-screen development indicator in Next.js, allowing you to set its position or hide it entirely.", "heading": "Version History", "content": "Page: devIndicators\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v16.0.0` | `appIsrStatus`, `buildActivity`, and `buildActivityPosition` options have been removed. |\n| `v15.2.0` | Improved on-screen indicator with new…", "code_blocks": [], "chunk_position": 41, "heading_path": "Version History > Version History", "breadcrumbs": "devIndicators > Version History > Version History"}, {"id": "c1f3d92498436254", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/distDir", "page_title": "distDir", "page_type": "reference", "page_summary": "Documentation for the distDir configuration option in next.config.js, which lets you specify a custom build directory instead of the default .next folder.", "heading": "distDir", "content": "Page: distDir\nSection: distDir\n\nYou can specify a name to use for a custom build directory to use instead of `.next`.\n\nOpen `next.config.js` and add the `distDir` config:\n\nNow if you run `next build` Next.js will use `build`…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  distDir: 'build',\n}", "filename": "next.config.js"}], "chunk_position": 42, "heading_path": "distDir > distDir", "breadcrumbs": "distDir > distDir > distDir"}, {"id": "46a85d5443f000a9", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/env", "page_title": "env", "page_type": "api", "page_summary": "Describes the legacy `env` config option in next.config.js for adding environment variables to the JavaScript bundle, noting it's no longer recommended.", "heading": "env", "content": "Page: env\nSection: env\n\nThis is a legacy API and no longer recommended. It's still supported for backward compatibility.\n\n> Since the release of [Next.js 9.4](https://nextjs.org/blog/next-9-4) we now have a more intuitive…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  env: {\n    customKey: 'my-value',\n  },\n}", "filename": "next.config.js"}, {"language": "jsx", "code": "function Page() {\n  return <h1>The value of customKey is: {process.env.customKey}</h1>\n}\n \nexport default Page", "filename": ""}, {"language": "jsx", "code": "return <h1>The value of customKey is: {process.env.customKey}</h1>", "filename": ""}, {"language": "jsx", "code": "return <h1>The value of customKey is: {'my-value'}</h1>", "filename": ""}], "chunk_position": 43, "heading_path": "env > env", "breadcrumbs": "env > env > env"}, {"id": "d6f1b2719041052a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/expireTime", "page_title": "expireTime", "page_type": "api", "page_summary": "Describes the `expireTime` configuration option in Next.js, which sets a custom stale-while-revalidate expire time for CDNs in the Cache-Control header for ISR pages.", "heading": "expireTime", "content": "Page: expireTime\nSection: expireTime\n\nYou can specify a custom `stale-while-revalidate` expire time for CDNs to consume in the `Cache-Control` header for ISR enabled pages.\n\nOpen `next.config.js` and add the `expireTime` config:\n\nNow…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  // one hour in seconds\n  expireTime: 3600,\n}", "filename": "next.config.js"}], "chunk_position": 44, "heading_path": "expireTime > expireTime", "breadcrumbs": "expireTime > expireTime > expireTime"}, {"id": "ef266ca2cae0fab1", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/exportPathMap", "page_title": "next.config.js: exportPathMap | Next.js", "page_type": "reference", "page_summary": "This page documents exportPathMap, a legacy Next.js configuration option for specifying a mapping of request paths to page destinations during static export.", "heading": "exportPathMap", "content": "Page: next.config.js: exportPathMap | Next.js\nSection: exportPathMap\n\nThis is a legacy API and no longer recommended. It's still supported for backward compatibility.\n\n> This feature is exclusive to `next export` and currently **deprecated** in favor of…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  exportPathMap: async function (\n    defaultPathMap,\n    { dev, dir, outDir, distDir, buildId }\n  ) {\n    return {\n      '/': { page: '/' },\n      '/about': { page: '/about' },…", "filename": "next.config.js"}], "chunk_position": 45, "heading_path": "exportPathMap > exportPathMap", "breadcrumbs": "next.config.js: exportPathMap | Next.js > exportPathMap > exportPathMap"}, {"id": "f1cede20d0191ba9", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/exportPathMap", "page_title": "next.config.js: exportPathMap | Next.js", "page_type": "reference", "page_summary": "This page documents exportPathMap, a legacy Next.js configuration option for specifying a mapping of request paths to page destinations during static export.", "heading": "Adding a trailing slash", "content": "Page: next.config.js: exportPathMap | Next.js\nSection: Adding a trailing slash\n\nIt is possible to configure Next.js to export pages as `index.html` files and require trailing slashes, `/about` becomes `/about/index.html` and is routable via `/about/`. This was the default…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  trailingSlash: true,\n}", "filename": "next.config.js"}], "chunk_position": 45, "heading_path": "Adding a trailing slash > Adding a trailing slash", "breadcrumbs": "next.config.js: exportPathMap | Next.js > Adding a trailing slash > Adding a trailing slash"}, {"id": "c15c5185011067a9", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/exportPathMap", "page_title": "next.config.js: exportPathMap | Next.js", "page_type": "reference", "page_summary": "This page documents exportPathMap, a legacy Next.js configuration option for specifying a mapping of request paths to page destinations during static export.", "heading": "Customizing the output directory", "content": "Page: next.config.js: exportPathMap | Next.js\nSection: Customizing the output directory\n\n[`next export`](/docs/app/guides/static-exports) will use `out` as the default output directory, you can customize this using the `-o` argument, like so:\n\n```terminal\nnext export -o outdir\n```\n\n>…", "code_blocks": [{"language": "bash", "code": "next export -o outdir", "filename": ""}], "chunk_position": 45, "heading_path": "Customizing the output directory > Customizing the output directory", "breadcrumbs": "next.config.js: exportPathMap | Next.js > Customizing the output directory > Customizing the output directory"}, {"id": "a6c93d43f6aa2783", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/generateBuildId", "page_title": "generateBuildId", "page_type": "api", "page_summary": "Explains how to use the generateBuildId option in next.config.js to generate a consistent build ID for your Next.js application.", "heading": "generateBuildId", "content": "Page: generateBuildId\nSection: generateBuildId\n\nNext.js generates an ID during `next build` to identify which version of your application is being served. The same build should be used and boot up multiple containers.\n\nIf you are rebuilding for…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  generateBuildId: async () => {\n    // This could be anything, using the latest git hash\n    return process.env.GIT_HASH\n  },\n}", "filename": "next.config.js"}], "chunk_position": 46, "heading_path": "generateBuildId > generateBuildId", "breadcrumbs": "generateBuildId > generateBuildId > generateBuildId"}, {"id": "d069f09edc37177c", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/generateEtags", "page_title": "generateEtags", "page_type": "api", "page_summary": "This page describes the `generateEtags` configuration option in `next.config.js`, which controls whether Next.js generates ETags for every page. It shows how to disable ETag generation for HTML pages.", "heading": "generateEtags", "content": "Page: generateEtags\nSection: generateEtags\n\nNext.js will generate [etags](https://en.wikipedia.org/wiki/HTTP_ETag) for every page by default. You may want to disable etag generation for HTML pages depending on your cache strategy.\n\nOpen…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  generateEtags: false,\n}", "filename": "next.config.js"}], "chunk_position": 47, "heading_path": "generateEtags > generateEtags", "breadcrumbs": "generateEtags > generateEtags > generateEtags"}, {"id": "bcd5121235e25e7a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "headers", "content": "Page: next.config.js: headers\nSection: headers\n\nHeaders allow you to set custom HTTP headers on the response to an incoming request on a given path.\n\nTo set custom HTTP headers you can use the `headers` key in `next.config.js`:\n\n`headers` can be…", "code_blocks": [{"language": "", "code": "module.exports = {\n  headers() {\n    return [\n      {\n        source: '/about',\n        headers: [\n          {\n            key: 'x-custom-header',\n            value: 'my custom header value',…", "filename": "next.config.js"}], "chunk_position": 48, "heading_path": "headers > headers", "breadcrumbs": "next.config.js: headers > headers > headers"}, {"id": "83d143146bb651f0", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Header Overriding Behavior", "content": "Page: next.config.js: headers\nSection: Header Overriding Behavior\n\nIf two headers match the same path and set the same header key, the last header key will override the first. Using the below headers, the path `/hello` will result in the header `x-hello` being…", "code_blocks": [{"language": "", "code": "module.exports = {\n  headers() {\n    return [\n      {\n        source: '/:path*',\n        headers: [\n          {\n            key: 'x-hello',\n            value: 'there',\n          },\n        ],…", "filename": "next.config.js"}], "chunk_position": 48, "heading_path": "Header Overriding Behavior > Header Overriding Behavior", "breadcrumbs": "next.config.js: headers > Header Overriding Behavior > Header Overriding Behavior"}, {"id": "bd04ce69c46b092b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Path Matching", "content": "Page: next.config.js: headers\nSection: Path Matching\n\nPath matches are allowed, for example `/blog/:slug` will match `/blog/first-post` (no nested paths):\n\nThe pattern `/blog/:slug` matches `/blog/first-post` and `/blog/post-1` but not a nested path…", "code_blocks": [{"language": "", "code": "module.exports = {\n  headers() {\n    return [\n      {\n        source: '/blog/:slug',\n        headers: [\n          {\n            key: 'x-slug',\n            value: ':slug', // Matched parameters can be…", "filename": "next.config.js"}], "chunk_position": 48, "heading_path": "Path Matching > Path Matching", "breadcrumbs": "next.config.js: headers > Path Matching > Path Matching"}, {"id": "bda51ac92cd688d2", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Wildcard Path Matching", "content": "Page: next.config.js: headers\nSection: Wildcard Path Matching\n\nTo match a wildcard path you can use `*` after a parameter, for example `/blog/:slug*` will match `/blog/a/b/c/d/hello-world`:", "code_blocks": [{"language": "", "code": "module.exports = {\n  headers() {\n    return [\n      {\n        source: '/blog/:slug*',\n        headers: [\n          {\n            key: 'x-slug',\n            value: ':slug*', // Matched parameters can…", "filename": "next.config.js"}], "chunk_position": 48, "heading_path": "Wildcard Path Matching > Wildcard Path Matching", "breadcrumbs": "next.config.js: headers > Wildcard Path Matching > Wildcard Path Matching"}, {"id": "9fc01adccb6afd82", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Regex Path Matching", "content": "Page: next.config.js: headers\nSection: Regex Path Matching\n\nTo match a regex path you can wrap the regex in parenthesis after a parameter, for example `/blog/:slug(\\d{1,})` will match `/blog/123` but not `/blog/abc`:\n\nThe following characters `(`, `)`, `{`,…", "code_blocks": [{"language": "", "code": "module.exports = {\n  headers() {\n    return [\n      {\n        source: '/blog/:post(\\\\d{1,})',\n        headers: [\n          {\n            key: 'x-post',\n            value: ':post',\n          },…", "filename": "next.config.js"}, {"language": "", "code": "module.exports = {\n  headers() {\n    return [\n      {\n        // this will match `/english(default)/something` being requested\n        source: '/english\\\\(default\\\\)/:slug',\n        headers: […", "filename": "next.config.js"}], "chunk_position": 48, "heading_path": "Regex Path Matching > Regex Path Matching", "breadcrumbs": "next.config.js: headers > Regex Path Matching > Regex Path Matching"}, {"id": "8c78e091d146bec0", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Header, Cookie, and Query Matching", "content": "Page: next.config.js: headers\nSection: Header, Cookie, and Query Matching\n\nTo only apply a header when header, cookie, or query values also match the `has` field or don't match the `missing` field can be used. Both the `source` and all `has` items must match and all…", "code_blocks": [{"language": "", "code": "module.exports = {\n  headers() {\n    return [\n      // if the header `x-add-header` is present,\n      // the `x-another-header` header will be applied\n      {\n        source: '/:path*',\n        has:…", "filename": "next.config.js"}], "chunk_position": 48, "heading_path": "Header, Cookie, and Query Matching > Header, Cookie, and Query Matching", "breadcrumbs": "next.config.js: headers > Header, Cookie, and Query Matching > Header, Cookie, and Query Matching"}, {"id": "7f468bed2707ebac", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Headers with basePath support", "content": "Page: next.config.js: headers\nSection: Headers with basePath support\n\nWhen leveraging [`basePath` support](/docs/app/api-reference/config/next-config-js/basePath) with headers each `source` is automatically prefixed with the `basePath` unless you add `basePath: false`…", "code_blocks": [{"language": "", "code": "module.exports = {\n  basePath: '/docs',\n \n  headers() {\n    return [\n      {\n        source: '/with-basePath', // becomes /docs/with-basePath\n        headers: [\n          {\n            key:…", "filename": "next.config.js"}], "chunk_position": 48, "heading_path": "Headers with basePath support > Headers with basePath support", "breadcrumbs": "next.config.js: headers > Headers with basePath support > Headers with basePath support"}, {"id": "67b6136291a0eee6", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Headers with i18n support", "content": "Page: next.config.js: headers\nSection: Headers with i18n support\n\nWhen leveraging [`i18n` support](/docs/app/guides/internationalization) with headers each `source` is automatically prefixed to handle the configured `locales` unless you add `locale: false` to the…", "code_blocks": [{"language": "", "code": "module.exports = {\n  i18n: {\n    locales: ['en', 'fr', 'de'],\n    defaultLocale: 'en',\n  },\n \n  headers() {\n    return [\n      {\n        source: '/with-locale', // automatically handles all locales…", "filename": "next.config.js"}], "chunk_position": 48, "heading_path": "Headers with i18n support > Headers with i18n support", "breadcrumbs": "next.config.js: headers > Headers with i18n support > Headers with i18n support"}, {"id": "230beb7674300e8a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Cache-Control", "content": "Page: next.config.js: headers\nSection: Cache-Control\n\nNext.js sets the `Cache-Control` header of `public, max-age=31536000, immutable` for truly immutable assets. It cannot be overridden. These immutable files contain a SHA-hash in the file name, so…", "code_blocks": [], "chunk_position": 48, "heading_path": "Cache-Control > Cache-Control", "breadcrumbs": "next.config.js: headers > Cache-Control > Cache-Control"}, {"id": "b7e2768d44ffc06b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "CORS", "content": "Page: next.config.js: headers\nSection: CORS\n\n[Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/docs/Web/HTTP/CORS) is a security feature that allows you to control which sites can access your resources. You can set the…", "code_blocks": [{"language": "", "code": "headers() {\n    return [\n      {\n        source: \"/api/:path*\",\n        headers: [\n          {\n            key: \"Access-Control-Allow-Origin\",\n            value: \"*\", // Set your origin\n          },…", "filename": ""}], "chunk_position": 48, "heading_path": "CORS > CORS", "breadcrumbs": "next.config.js: headers > CORS > CORS"}, {"id": "2526796c401f24d3", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "X-DNS-Prefetch-Control", "content": "Page: next.config.js: headers\nSection: X-DNS-Prefetch-Control\n\n[This header](https://developer.mozilla.org/docs/Web/HTTP/Headers/X-DNS-Prefetch-Control) controls DNS prefetching, allowing browsers to proactively perform domain name resolution on external links,…", "code_blocks": [{"language": "", "code": "{\n  key: 'X-DNS-Prefetch-Control',\n  value: 'on'\n}", "filename": ""}], "chunk_position": 48, "heading_path": "X-DNS-Prefetch-Control > X-DNS-Prefetch-Control", "breadcrumbs": "next.config.js: headers > X-DNS-Prefetch-Control > X-DNS-Prefetch-Control"}, {"id": "863ea32613af1503", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Strict-Transport-Security", "content": "Page: next.config.js: headers\nSection: Strict-Transport-Security\n\n[This header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Strict-Transport-Security) informs browsers it should only be accessed using HTTPS, instead of using HTTP. Using the configuration…", "code_blocks": [{"language": "", "code": "{\n  key: 'Strict-Transport-Security',\n  value: 'max-age=63072000; includeSubDomains; preload'\n}", "filename": ""}], "chunk_position": 48, "heading_path": "Strict-Transport-Security > Strict-Transport-Security", "breadcrumbs": "next.config.js: headers > Strict-Transport-Security > Strict-Transport-Security"}, {"id": "597186dcc1292729", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "X-Frame-Options", "content": "Page: next.config.js: headers\nSection: X-Frame-Options\n\n[This header](https://developer.mozilla.org/docs/Web/HTTP/Headers/X-Frame-Options) indicates whether the site should be allowed to be displayed within an `iframe`. This can prevent against…", "code_blocks": [{"language": "", "code": "{\n  key: 'X-Frame-Options',\n  value: 'SAMEORIGIN'\n}", "filename": ""}], "chunk_position": 48, "heading_path": "X-Frame-Options > X-Frame-Options", "breadcrumbs": "next.config.js: headers > X-Frame-Options > X-Frame-Options"}, {"id": "b702897f34c6407a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Permissions-Policy", "content": "Page: next.config.js: headers\nSection: Permissions-Policy\n\n[This header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Permissions-Policy) allows you to control which features and APIs can be used in the browser. It was previously named…", "code_blocks": [{"language": "", "code": "{\n  key: 'Permissions-Policy',\n  value: 'camera=(), microphone=(), geolocation=(), browsing-topics=()'\n}", "filename": ""}], "chunk_position": 48, "heading_path": "Permissions-Policy > Permissions-Policy", "breadcrumbs": "next.config.js: headers > Permissions-Policy > Permissions-Policy"}, {"id": "b1ef8bc1a5f0b7a9", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "X-Content-Type-Options", "content": "Page: next.config.js: headers\nSection: X-Content-Type-Options\n\n[This header](https://developer.mozilla.org/docs/Web/HTTP/Headers/X-Content-Type-Options) prevents the browser from attempting to guess the type of content if the `Content-Type` header is not…", "code_blocks": [{"language": "", "code": "{\n  key: 'X-Content-Type-Options',\n  value: 'nosniff'\n}", "filename": ""}], "chunk_position": 48, "heading_path": "X-Content-Type-Options > X-Content-Type-Options", "breadcrumbs": "next.config.js: headers > X-Content-Type-Options > X-Content-Type-Options"}, {"id": "b73ca544d2944949", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Referrer-Policy", "content": "Page: next.config.js: headers\nSection: Referrer-Policy\n\n[This header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Referrer-Policy) controls how much information the browser includes when navigating from the current website (origin) to another.", "code_blocks": [{"language": "", "code": "{\n  key: 'Referrer-Policy',\n  value: 'origin-when-cross-origin'\n}", "filename": ""}], "chunk_position": 48, "heading_path": "Referrer-Policy > Referrer-Policy", "breadcrumbs": "next.config.js: headers > Referrer-Policy > Referrer-Policy"}, {"id": "abdf928e16068189", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Content-Security-Policy", "content": "Page: next.config.js: headers\nSection: Content-Security-Policy\n\nLearn more about adding a [Content Security Policy](/docs/app/guides/content-security-policy) to your application.", "code_blocks": [], "chunk_position": 48, "heading_path": "Content-Security-Policy > Content-Security-Policy", "breadcrumbs": "next.config.js: headers > Content-Security-Policy > Content-Security-Policy"}, {"id": "c80909629020322f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/headers", "page_title": "next.config.js: headers", "page_type": "api", "page_summary": "This page explains how to set custom HTTP headers on responses in Next.js using the `headers` key in `next.config.js`, covering path matching, regex, header/cookie/query matching, basePath/i18n…", "heading": "Version History", "content": "Page: next.config.js: headers\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v13.3.0` | `missing` added. |\n| `v10.2.0` | `has` added. |\n| `v9.5.0` | Headers added. |", "code_blocks": [], "chunk_position": 48, "heading_path": "Version History > Version History", "breadcrumbs": "next.config.js: headers > Version History > Version History"}, {"id": "9086ac2c61207d5d", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/htmlLimitedBots", "page_title": "htmlLimitedBots", "page_type": "api", "page_summary": "The `htmlLimitedBots` config allows you to specify a list of user agents that should receive blocking metadata instead of streaming metadata in Next.js.", "heading": "htmlLimitedBots", "content": "Page: htmlLimitedBots\nSection: htmlLimitedBots\n\nThe `htmlLimitedBots` config allows you to specify a list of user agents that should receive blocking metadata instead of [streaming…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst config: NextConfig = {\n  htmlLimitedBots: /MySpecialBot|MyAnotherSpecialBot|SimpleCrawler/,\n}\n \nexport default config", "filename": ""}], "chunk_position": 49, "heading_path": "htmlLimitedBots > htmlLimitedBots", "breadcrumbs": "htmlLimitedBots > htmlLimitedBots > htmlLimitedBots"}, {"id": "100f8837f6a912dd", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/htmlLimitedBots", "page_title": "htmlLimitedBots", "page_type": "api", "page_summary": "The `htmlLimitedBots` config allows you to specify a list of user agents that should receive blocking metadata instead of streaming metadata in Next.js.", "heading": "Default list", "content": "Page: htmlLimitedBots\nSection: Default list\n\nNext.js includes a default list of HTML limited bots, including:\n\n- Google crawlers (e.g. Mediapartners-Google, AdsBot-Google, Google-PageRenderer)\n- Bingbot\n- Twitterbot\n- Slackbot\n\nSee the full…", "code_blocks": [{"language": "typescript", "code": "const config: NextConfig = {\n  htmlLimitedBots: /MySpecialBot|MyAnotherSpecialBot|SimpleCrawler/,\n}\n \nexport default config", "filename": ""}], "chunk_position": 49, "heading_path": "Default list > Default list", "breadcrumbs": "htmlLimitedBots > Default list > Default list"}, {"id": "d55056388db0826a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/htmlLimitedBots", "page_title": "htmlLimitedBots", "page_type": "api", "page_summary": "The `htmlLimitedBots` config allows you to specify a list of user agents that should receive blocking metadata instead of streaming metadata in Next.js.", "heading": "Version History", "content": "Page: htmlLimitedBots\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| 15.2.0 | `htmlLimitedBots` option introduced. |", "code_blocks": [], "chunk_position": 49, "heading_path": "Version History > Version History", "breadcrumbs": "htmlLimitedBots > Version History > Version History"}, {"id": "a5915d94aff3ead9", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/httpAgentOptions", "page_title": "httpAgentOptions", "page_type": "reference", "page_summary": "Explains the httpAgentOptions configuration in next.config.js, which controls HTTP Keep-Alive behavior for server-side fetch() calls. Shows how to disable Keep-Alive by setting keepAlive to false.", "heading": "httpAgentOptions", "content": "Page: httpAgentOptions\nSection: httpAgentOptions\n\nIn Node.js versions prior to 18, Next.js automatically polyfills `fetch()` with [undici](/docs/architecture/supported-browsers#polyfills) and enables [HTTP…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  httpAgentOptions: {\n    keepAlive: false,\n  },\n}", "filename": "next.config.js"}], "chunk_position": 50, "heading_path": "httpAgentOptions > httpAgentOptions", "breadcrumbs": "httpAgentOptions > httpAgentOptions > httpAgentOptions"}, {"id": "b31b4e9df238817e", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "images", "content": "Page: next.config.js: images\nSection: images\n\nIf you want to use a cloud provider to optimize images instead of using the Next.js built-in Image Optimization API, you can configure `next.config.js` with the following:\n\nThis `loaderFile` must…", "code_blocks": [{"language": "", "code": "module.exports = {\n  images: {\n    loader: 'custom',\n    loaderFile: './my/image/loader.js',\n  },\n}", "filename": "next.config.js"}, {"language": "", "code": "'use client'\n \nexport default function myImageLoader({ src, width, quality }) {\n  return `https://example.com/${src}?w=${width}&q=${quality || 75}`\n}", "filename": "my/image/loader.js"}], "chunk_position": 51, "heading_path": "images > images", "breadcrumbs": "next.config.js: images > images > images"}, {"id": "18c0a6479e7b828e", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "Akamai", "content": "Page: next.config.js: images\nSection: Akamai\n\n```\n// Docs: https://techdocs.akamai.com/ivm/reference/test-images-on-demand\nexport default function akamaiLoader({ src, width, quality }) {\n  return `https://example.com/${src}?imwidth=${width}`\n}\n```", "code_blocks": [{"language": "", "code": "// Docs: https://techdocs.akamai.com/ivm/reference/test-images-on-demand\nexport default function akamaiLoader({ src, width, quality }) {\n  return `https://example.com/${src}?imwidth=${width}`\n}", "filename": ""}], "chunk_position": 51, "heading_path": "Akamai > Akamai", "breadcrumbs": "next.config.js: images > Akamai > Akamai"}, {"id": "3828c103265272b5", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "AWS CloudFront", "content": "Page: next.config.js: images\nSection: AWS CloudFront\n\n```\n// Docs: https://aws.amazon.com/developer/application-security-performance/articles/image-optimization\nexport default function cloudfrontLoader({ src, width, quality }) {\n  const url = new…\n```", "code_blocks": [{"language": "", "code": "// Docs: https://aws.amazon.com/developer/application-security-performance/articles/image-optimization\nexport default function cloudfrontLoader({ src, width, quality }) {\n  const url = new…", "filename": ""}], "chunk_position": 51, "heading_path": "AWS CloudFront > AWS CloudFront", "breadcrumbs": "next.config.js: images > AWS CloudFront > AWS CloudFront"}, {"id": "f20d7233e7f1189f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "Cloudinary", "content": "Page: next.config.js: images\nSection: Cloudinary\n\n```\n// Demo: https://res.cloudinary.com/demo/image/upload/w_300,c_limit,q_auto/turtles.jpg\nexport default function cloudinaryLoader({ src, width, quality }) {\n  const params = ['f_auto', 'c_limit',…\n```", "code_blocks": [{"language": "", "code": "// Demo: https://res.cloudinary.com/demo/image/upload/w_300,c_limit,q_auto/turtles.jpg\nexport default function cloudinaryLoader({ src, width, quality }) {\n  const params = ['f_auto', 'c_limit',…", "filename": ""}], "chunk_position": 51, "heading_path": "Cloudinary > Cloudinary", "breadcrumbs": "next.config.js: images > Cloudinary > Cloudinary"}, {"id": "3f7388436f5b5eda", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "Cloudflare", "content": "Page: next.config.js: images\nSection: Cloudflare\n\n```\n// Docs: https://developers.cloudflare.com/images/transform-images\nexport default function cloudflareLoader({ src, width, quality }) {\n  const params = [`width=${width}`, `quality=${quality || 75}`,…\n```", "code_blocks": [{"language": "", "code": "// Docs: https://developers.cloudflare.com/images/transform-images\nexport default function cloudflareLoader({ src, width, quality }) {\n  const params = [`width=${width}`, `quality=${quality || 75}`,…", "filename": ""}], "chunk_position": 51, "heading_path": "Cloudflare > Cloudflare", "breadcrumbs": "next.config.js: images > Cloudflare > Cloudflare"}, {"id": "f7c074df5f5418c3", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "Contentful", "content": "Page: next.config.js: images\nSection: Contentful\n\n```\n// Docs: https://www.contentful.com/developers/docs/references/images-api/\nexport default function contentfulLoader({ src, width, quality }) {\n  const url = new URL(`https://example.com${src}`)…\n```", "code_blocks": [{"language": "", "code": "// Docs: https://www.contentful.com/developers/docs/references/images-api/\nexport default function contentfulLoader({ src, width, quality }) {\n  const url = new URL(`https://example.com${src}`)…", "filename": ""}], "chunk_position": 51, "heading_path": "Contentful > Contentful", "breadcrumbs": "next.config.js: images > Contentful > Contentful"}, {"id": "50a99f390f9d4ac1", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "Fastly", "content": "Page: next.config.js: images\nSection: Fastly\n\n```\n// Docs: https://developer.fastly.com/reference/io/\nexport default function fastlyLoader({ src, width, quality }) {\n  const url = new URL(`https://example.com${src}`)\n  url.searchParams.set('auto',…\n```", "code_blocks": [{"language": "", "code": "// Docs: https://developer.fastly.com/reference/io/\nexport default function fastlyLoader({ src, width, quality }) {\n  const url = new URL(`https://example.com${src}`)\n  url.searchParams.set('auto',…", "filename": ""}], "chunk_position": 51, "heading_path": "Fastly > Fastly", "breadcrumbs": "next.config.js: images > Fastly > Fastly"}, {"id": "c2f5cf9f6fabebb1", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "Gumlet", "content": "Page: next.config.js: images\nSection: Gumlet\n\n```\n// Docs: https://docs.gumlet.com/reference/image-transform-size\nexport default function gumletLoader({ src, width, quality }) {\n  const url = new URL(`https://example.com${src}`)…\n```", "code_blocks": [{"language": "", "code": "// Docs: https://docs.gumlet.com/reference/image-transform-size\nexport default function gumletLoader({ src, width, quality }) {\n  const url = new URL(`https://example.com${src}`)…", "filename": ""}], "chunk_position": 51, "heading_path": "Gumlet > Gumlet", "breadcrumbs": "next.config.js: images > Gumlet > Gumlet"}, {"id": "0c5891ecd2db7be3", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "ImageEngine", "content": "Page: next.config.js: images\nSection: ImageEngine\n\n```\n// Docs: https://support.imageengine.io/hc/en-us/articles/360058880672-Directives\nexport default function imageengineLoader({ src, width, quality }) {\n  const compression = 100 - (quality || 50)…\n```", "code_blocks": [{"language": "", "code": "// Docs: https://support.imageengine.io/hc/en-us/articles/360058880672-Directives\nexport default function imageengineLoader({ src, width, quality }) {\n  const compression = 100 - (quality || 50)…", "filename": ""}], "chunk_position": 51, "heading_path": "ImageEngine > ImageEngine", "breadcrumbs": "next.config.js: images > ImageEngine > ImageEngine"}, {"id": "90eb141fa993714e", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "Imgix", "content": "Page: next.config.js: images\nSection: Imgix\n\n```\n// Demo: https://static.imgix.net/daisy.png?format=auto&fit=max&w=300\nexport default function imgixLoader({ src, width, quality }) {\n  const url = new URL(`https://example.com${src}`)\n  const params…\n```", "code_blocks": [{"language": "", "code": "// Demo: https://static.imgix.net/daisy.png?format=auto&fit=max&w=300\nexport default function imgixLoader({ src, width, quality }) {\n  const url = new URL(`https://example.com${src}`)\n  const params…", "filename": ""}], "chunk_position": 51, "heading_path": "Imgix > Imgix", "breadcrumbs": "next.config.js: images > Imgix > Imgix"}, {"id": "f9c1b95d59ebceda", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "PixelBin", "content": "Page: next.config.js: images\nSection: PixelBin\n\n```\n// Doc (Resize): https://www.pixelbin.io/docs/transformations/basic/resize/#width-w\n// Doc (Optimise): https://www.pixelbin.io/docs/optimizations/quality/#image-quality-when-delivering\n// Doc (Auto…\n```", "code_blocks": [{"language": "", "code": "// Doc (Resize): https://www.pixelbin.io/docs/transformations/basic/resize/#width-w\n// Doc (Optimise): https://www.pixelbin.io/docs/optimizations/quality/#image-quality-when-delivering\n// Doc (Auto…", "filename": ""}], "chunk_position": 51, "heading_path": "PixelBin > PixelBin", "breadcrumbs": "next.config.js: images > PixelBin > PixelBin"}, {"id": "4d814bfb2ddc9fbb", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "Sanity", "content": "Page: next.config.js: images\nSection: Sanity\n\n```\n// Docs: https://www.sanity.io/docs/image-urls\nexport default function sanityLoader({ src, width, quality }) {\n  const prj = 'zp7mbokg'\n  const dataset = 'production'\n  const url = new…\n```", "code_blocks": [{"language": "", "code": "// Docs: https://www.sanity.io/docs/image-urls\nexport default function sanityLoader({ src, width, quality }) {\n  const prj = 'zp7mbokg'\n  const dataset = 'production'\n  const url = new…", "filename": ""}], "chunk_position": 51, "heading_path": "Sanity > Sanity", "breadcrumbs": "next.config.js: images > Sanity > Sanity"}, {"id": "82e8584ddb77054f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "Sirv", "content": "Page: next.config.js: images\nSection: Sirv\n\n```\n// Docs: https://sirv.com/help/articles/dynamic-imaging/\nexport default function sirvLoader({ src, width, quality }) {\n  const url = new URL(`https://example.com${src}`)\n  const params =…\n```", "code_blocks": [{"language": "", "code": "// Docs: https://sirv.com/help/articles/dynamic-imaging/\nexport default function sirvLoader({ src, width, quality }) {\n  const url = new URL(`https://example.com${src}`)\n  const params =…", "filename": ""}], "chunk_position": 51, "heading_path": "Sirv > Sirv", "breadcrumbs": "next.config.js: images > Sirv > Sirv"}, {"id": "641d90b9e3ce6834", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "Supabase", "content": "Page: next.config.js: images\nSection: Supabase\n\n```\n// Docs: https://supabase.com/docs/guides/storage/image-transformations#nextjs-loader\nexport default function supabaseLoader({ src, width, quality }) {\n  const url = new…\n```", "code_blocks": [{"language": "", "code": "// Docs: https://supabase.com/docs/guides/storage/image-transformations#nextjs-loader\nexport default function supabaseLoader({ src, width, quality }) {\n  const url = new…", "filename": ""}], "chunk_position": 51, "heading_path": "Supabase > Supabase", "breadcrumbs": "next.config.js: images > Supabase > Supabase"}, {"id": "e2ddd26c62cd76ca", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "Thumbor", "content": "Page: next.config.js: images\nSection: Thumbor\n\n```\n// Docs: https://thumbor.readthedocs.io/en/latest/\nexport default function thumborLoader({ src, width, quality }) {\n  const params = [`${width}x0`, `filters:quality(${quality || 75})`]\n  return…\n```", "code_blocks": [{"language": "", "code": "// Docs: https://thumbor.readthedocs.io/en/latest/\nexport default function thumborLoader({ src, width, quality }) {\n  const params = [`${width}x0`, `filters:quality(${quality || 75})`]\n  return…", "filename": ""}], "chunk_position": 51, "heading_path": "Thumbor > Thumbor", "breadcrumbs": "next.config.js: images > Thumbor > Thumbor"}, {"id": "0da3c9e803fc628e", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "ImageKit.io", "content": "Page: next.config.js: images\nSection: ImageKit.io\n\n```\n// Docs: https://imagekit.io/docs/image-transformation\nexport default function imageKitLoader({ src, width, quality }) {\n  const params = [`w-${width}`, `q-${quality || 80}`]\n  return…\n```", "code_blocks": [{"language": "", "code": "// Docs: https://imagekit.io/docs/image-transformation\nexport default function imageKitLoader({ src, width, quality }) {\n  const params = [`w-${width}`, `q-${quality || 80}`]\n  return…", "filename": ""}], "chunk_position": 51, "heading_path": "ImageKit.io > ImageKit.io", "breadcrumbs": "next.config.js: images > ImageKit.io > ImageKit.io"}, {"id": "c295fed9f8886a91", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/images", "page_title": "next.config.js: images", "page_type": "reference", "page_summary": "This page explains how to configure the `images` option in `next.config.js` to use a custom image loader for cloud providers, including example loader implementations for various providers.", "heading": "Nitrogen AIO", "content": "Page: next.config.js: images\nSection: Nitrogen AIO\n\n```\n// Docs: https://docs.n7.io/aio/intergrations/\nexport default function aioLoader({ src, width, quality }) {\n  const url = new URL(src, window.location.href)\n  const params = url.searchParams\n  const…\n```", "code_blocks": [{"language": "", "code": "// Docs: https://docs.n7.io/aio/intergrations/\nexport default function aioLoader({ src, width, quality }) {\n  const url = new URL(src, window.location.href)\n  const params = url.searchParams\n  const…", "filename": ""}], "chunk_position": 51, "heading_path": "Nitrogen AIO > Nitrogen AIO", "breadcrumbs": "next.config.js: images > Nitrogen AIO > Nitrogen AIO"}, {"id": "4cc2bdde64950128", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/incrementalCacheHandlerPath", "page_title": "Custom Next.js Cache Handler", "page_type": "api", "page_summary": "Explains how to configure a custom cache handler in next.config.js to persist cached pages and data to durable storage or share cache across instances, including method signatures and image…", "heading": "Custom Next.js Cache Handler", "content": "Page: Custom Next.js Cache Handler\nSection: Custom Next.js Cache Handler\n\nYou can configure the Next.js cache location if you want to persist cached pages and data to durable storage, or share the cache across multiple containers or instances of your Next.js…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  cacheHandler: require.resolve('./cache-handler.js'),\n  cacheMaxMemorySize: 0, // disable default in-memory caching\n}", "filename": ""}], "chunk_position": 52, "heading_path": "Custom Next.js Cache Handler > Custom Next.js Cache Handler", "breadcrumbs": "Custom Next.js Cache Handler > Custom Next.js Cache Handler > Custom Next.js Cache Handler"}, {"id": "e63ce91b7b485591", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/incrementalCacheHandlerPath", "page_title": "Custom Next.js Cache Handler", "page_type": "api", "page_summary": "Explains how to configure a custom cache handler in next.config.js to persist cached pages and data to durable storage or share cache across instances, including method signatures and image…", "heading": "API Reference", "content": "Page: Custom Next.js Cache Handler\nSection: API Reference\n\nThe cache handler can implement the following methods: `get`, `set`, `revalidateTag`, and `resetRequestCache`.", "code_blocks": [], "chunk_position": 52, "heading_path": "API Reference > API Reference", "breadcrumbs": "Custom Next.js Cache Handler > API Reference > API Reference"}, {"id": "33cfe5da8eae267e", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/incrementalCacheHandlerPath", "page_title": "Custom Next.js Cache Handler", "page_type": "api", "page_summary": "Explains how to configure a custom cache handler in next.config.js to persist cached pages and data to durable storage or share cache across instances, including method signatures and image…", "heading": "get()", "content": "Page: Custom Next.js Cache Handler\nSection: get()\n\nThe `ctx` parameter contains a `kind` property that indicates the type of cache entry being retrieved. Possible values include `'APP_PAGE'`, `'APP_ROUTE'`, `'PAGES'`, `'FETCH'`, and…", "code_blocks": [], "chunk_position": 52, "heading_path": "get() > get()", "breadcrumbs": "Custom Next.js Cache Handler > get() > get()"}, {"id": "45e3f273b9c6b7b1", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/incrementalCacheHandlerPath", "page_title": "Custom Next.js Cache Handler", "page_type": "api", "page_summary": "Explains how to configure a custom cache handler in next.config.js to persist cached pages and data to durable storage or share cache across instances, including method signatures and image…", "heading": "set()", "content": "Page: Custom Next.js Cache Handler\nSection: set()\n\nThe `data` object contains a `kind` property that indicates the type of cache entry. For image optimization, `kind` will be `'IMAGE'` and the data will include properties like `buffer`, `etag`,…", "code_blocks": [], "chunk_position": 52, "heading_path": "set() > set()", "breadcrumbs": "Custom Next.js Cache Handler > set() > set()"}, {"id": "6eb49e222f9e1b0d", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/incrementalCacheHandlerPath", "page_title": "Custom Next.js Cache Handler", "page_type": "api", "page_summary": "Explains how to configure a custom cache handler in next.config.js to persist cached pages and data to durable storage or share cache across instances, including method signatures and image…", "heading": "revalidateTag()", "content": "Page: Custom Next.js Cache Handler\nSection: revalidateTag()\n\nReturns `Promise<void>`. Learn more about [revalidating data](/docs/app/guides/incremental-static-regeneration) or the [`revalidateTag()`](/docs/app/api-reference/functions/revalidateTag)…", "code_blocks": [], "chunk_position": 52, "heading_path": "revalidateTag() > revalidateTag()", "breadcrumbs": "Custom Next.js Cache Handler > revalidateTag() > revalidateTag()"}, {"id": "74f1e7945555072f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/incrementalCacheHandlerPath", "page_title": "Custom Next.js Cache Handler", "page_type": "api", "page_summary": "Explains how to configure a custom cache handler in next.config.js to persist cached pages and data to durable storage or share cache across instances, including method signatures and image…", "heading": "resetRequestCache()", "content": "Page: Custom Next.js Cache Handler\nSection: resetRequestCache()\n\nThis method resets the temporary in-memory cache for a single request before the next request.\n\nReturns `void`.\n\n**Good to know:**\n\n- `revalidatePath` is a convenience layer on top of cache tags.…", "code_blocks": [], "chunk_position": 52, "heading_path": "resetRequestCache() > resetRequestCache()", "breadcrumbs": "Custom Next.js Cache Handler > resetRequestCache() > resetRequestCache()"}, {"id": "f14f1648b709e601", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/incrementalCacheHandlerPath", "page_title": "Custom Next.js Cache Handler", "page_type": "api", "page_summary": "Explains how to configure a custom cache handler in next.config.js to persist cached pages and data to durable storage or share cache across instances, including method signatures and image…", "heading": "Image Optimization Caching", "content": "Page: Custom Next.js Cache Handler\nSection: Image Optimization Caching\n\nThe `cacheHandler` can also be used for caching optimized images from `next/image`. To enable this, set `images.customCacheHandler` to `true` in your `next.config.js`:\n\n> **Good to know** : This…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  cacheHandler: require.resolve('./cache-handler.js'),\n  images: {\n    customCacheHandler: true,\n  },\n}", "filename": ""}], "chunk_position": 52, "heading_path": "Image Optimization Caching > Image Optimization Caching", "breadcrumbs": "Custom Next.js Cache Handler > Image Optimization Caching > Image Optimization Caching"}, {"id": "a57d82c1d2b3fa62", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/incrementalCacheHandlerPath", "page_title": "Custom Next.js Cache Handler", "page_type": "api", "page_summary": "Explains how to configure a custom cache handler in next.config.js to persist cached pages and data to durable storage or share cache across instances, including method signatures and image…", "heading": "Platform Support", "content": "Page: Custom Next.js Cache Handler\nSection: Platform Support\n\n| Deployment Option | Supported |\n| --- | --- |\n| [Node.js server](/docs/app/getting-started/deploying#nodejs-server) | Yes |\n| [Docker container](/docs/app/getting-started/deploying#docker) | Yes…", "code_blocks": [], "chunk_position": 52, "heading_path": "Platform Support > Platform Support", "breadcrumbs": "Custom Next.js Cache Handler > Platform Support > Platform Support"}, {"id": "7a8f60dfbe04248e", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/incrementalCacheHandlerPath", "page_title": "Custom Next.js Cache Handler", "page_type": "api", "page_summary": "Explains how to configure a custom cache handler in next.config.js to persist cached pages and data to durable storage or share cache across instances, including method signatures and image…", "heading": "Version History", "content": "Page: Custom Next.js Cache Handler\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v16.2.0` | `cacheHandler` support for image optimization caching. |\n| `v14.1.0` | Renamed to `cacheHandler` and became stable. |\n| `v13.4.0` |…", "code_blocks": [], "chunk_position": 52, "heading_path": "Version History > Version History", "breadcrumbs": "Custom Next.js Cache Handler > Version History > Version History"}, {"id": "2fae703ebc17c972", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/inlineCss", "page_title": "next.config.js: inlineCss | Next.js", "page_type": "api", "page_summary": "Experimental Next.js configuration option that inlines CSS into the <head> by generating <style> tags instead of <link> tags, including trade-offs, benefits, and known limitations.", "heading": "inlineCss", "content": "Page: next.config.js: inlineCss | Next.js\nSection: inlineCss\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on [GitHub](https://github.com/vercel/next.js/issues).", "code_blocks": [], "chunk_position": 53, "heading_path": "inlineCss > inlineCss", "breadcrumbs": "next.config.js: inlineCss | Next.js > inlineCss > inlineCss"}, {"id": "6cfe0d0e3c9c50d5", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/inlineCss", "page_title": "next.config.js: inlineCss | Next.js", "page_type": "api", "page_summary": "Experimental Next.js configuration option that inlines CSS into the <head> by generating <style> tags instead of <link> tags, including trade-offs, benefits, and known limitations.", "heading": "Usage", "content": "Page: next.config.js: inlineCss | Next.js\nSection: Usage\n\nExperimental support for inlining CSS in the ``. When this flag is enabled, all places where we normally generate a `<link>` tag will instead have a generated `<style>` tag.", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    inlineCss: true,\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 53, "heading_path": "Usage > Usage", "breadcrumbs": "next.config.js: inlineCss | Next.js > Usage > Usage"}, {"id": "6599b09ae312c2b1", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/inlineCss", "page_title": "next.config.js: inlineCss | Next.js", "page_type": "api", "page_summary": "Experimental Next.js configuration option that inlines CSS into the <head> by generating <style> tags instead of <link> tags, including trade-offs, benefits, and known limitations.", "heading": "Trade-Offs", "content": "Page: next.config.js: inlineCss | Next.js\nSection: Trade-Offs\n\n- **Enable** if you use atomic CSS (like Tailwind) and want to optimize first-load performance for new visitors\n- **Skip** if returning visitors are common and you want them to benefit from cached…", "code_blocks": [], "chunk_position": 53, "heading_path": "Trade-Offs > Trade-Offs", "breadcrumbs": "next.config.js: inlineCss | Next.js > Trade-Offs > Trade-Offs"}, {"id": "0225463d2b6432eb", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/inlineCss", "page_title": "next.config.js: inlineCss | Next.js", "page_type": "api", "page_summary": "Experimental Next.js configuration option that inlines CSS into the <head> by generating <style> tags instead of <link> tags, including trade-offs, benefits, and known limitations.", "heading": "When Inline CSS Helps", "content": "Page: next.config.js: inlineCss | Next.js\nSection: When Inline CSS Helps\n\nNormally, the browser must download HTML, parse it, discover CSS `<link>` tags, then request stylesheets before it can render. Inlining [eliminates this request…", "code_blocks": [], "chunk_position": 53, "heading_path": "When Inline CSS Helps > When Inline CSS Helps", "breadcrumbs": "next.config.js: inlineCss | Next.js > When Inline CSS Helps > When Inline CSS Helps"}, {"id": "3a5d064612841daa", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/inlineCss", "page_title": "next.config.js: inlineCss | Next.js", "page_type": "api", "page_summary": "Experimental Next.js configuration option that inlines CSS into the <head> by generating <style> tags instead of <link> tags, including trade-offs, benefits, and known limitations.", "heading": "When External CSS is Better", "content": "Page: next.config.js: inlineCss | Next.js\nSection: When External CSS is Better\n\nInlined styles cannot be cached separately from HTML. Every page load re-downloads the same CSS.\n\nThis trade-off matters most with:\n\n- **Returning visitors**: Users who visit your site repeatedly…", "code_blocks": [], "chunk_position": 53, "heading_path": "When External CSS is Better > When External CSS is Better", "breadcrumbs": "next.config.js: inlineCss | Next.js > When External CSS is Better > When External CSS is Better"}, {"id": "2d229d9d33c01603", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/inlineCss", "page_title": "next.config.js: inlineCss | Next.js", "page_type": "api", "page_summary": "Experimental Next.js configuration option that inlines CSS into the <head> by generating <style> tags instead of <link> tags, including trade-offs, benefits, and known limitations.", "heading": "Good to know", "content": "Page: next.config.js: inlineCss | Next.js\nSection: Good to know\n\nThis feature is currently experimental and has some known limitations:\n\n- CSS inlining is applied globally and cannot be configured on a per-page basis\n- Styles are duplicated during initial page…", "code_blocks": [], "chunk_position": 53, "heading_path": "Good to know > Good to know", "breadcrumbs": "next.config.js: inlineCss | Next.js > Good to know > Good to know"}, {"id": "c8da2992b8eb685d", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/instrumentationClientInject", "page_title": "next.config.js: instrumentationClientInject | Next.js", "page_type": "api", "page_summary": "This page documents the `instrumentationClientInject` option in `next.config.js`, which allows plugins to inject client-side instrumentation modules that run before the user's…", "heading": "instrumentationClientInject", "content": "Page: next.config.js: instrumentationClientInject | Next.js\nSection: instrumentationClientInject\n\n`instrumentationClientInject` is a list of modules that are imported on the client for their side effects before the user's…", "code_blocks": [{"language": "js", "code": "module.exports = function withMyInstrumentation(nextConfig = {}) {\n  return {\n    ...nextConfig,\n    instrumentationClientInject: [\n      ...(nextConfig.instrumentationClientInject ?? []),…", "filename": "withMyInstrumentation.js"}, {"language": "js", "code": "/** @type {import('next').NextConfig} */\nmodule.exports = {\n  instrumentationClientInject: [\n    'my-analytics-package',\n    './lib/sentry-client.js',\n  ],\n}", "filename": "next.config.js"}], "chunk_position": 54, "heading_path": "instrumentationClientInject > instrumentationClientInject", "breadcrumbs": "next.config.js: instrumentationClientInject | Next.js > instrumentationClientInject > instrumentationClientInject"}, {"id": "ec821542dcc9de2f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/instrumentationClientInject", "page_title": "next.config.js: instrumentationClientInject | Next.js", "page_type": "api", "page_summary": "This page documents the `instrumentationClientInject` option in `next.config.js`, which allows plugins to inject client-side instrumentation modules that run before the user's…", "heading": "Execution order", "content": "Page: next.config.js: instrumentationClientInject | Next.js\nSection: Execution order\n\nModules run on the client in this order:\n\n- Each entry in `instrumentationClientInject`, in array order.\n- The project's `instrumentation-client.{js,ts}` file, if present.\n- React hydration.", "code_blocks": [], "chunk_position": 54, "heading_path": "Execution order > Execution order", "breadcrumbs": "next.config.js: instrumentationClientInject | Next.js > Execution order > Execution order"}, {"id": "16cdda8a9b07b181", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/instrumentationClientInject", "page_title": "next.config.js: instrumentationClientInject | Next.js", "page_type": "api", "page_summary": "This page documents the `instrumentationClientInject` option in `next.config.js`, which allows plugins to inject client-side instrumentation modules that run before the user's…", "heading": "Router navigation hook", "content": "Page: next.config.js: instrumentationClientInject | Next.js\nSection: Router navigation hook\n\nEach injected module may optionally export an `onRouterTransitionStart` function with the same signature as the one documented for the [`instrumentation-client` file…", "code_blocks": [{"language": "js", "code": "// Side-effectful setup runs at load time.\nsetupSentry()\n \nexport function onRouterTransitionStart(url, navigationType) {\n  recordNavigationBreadcrumb(url, navigationType)\n}", "filename": "lib/sentry-client.js"}], "chunk_position": 54, "heading_path": "Router navigation hook > Router navigation hook", "breadcrumbs": "next.config.js: instrumentationClientInject | Next.js > Router navigation hook > Router navigation hook"}, {"id": "522feabb12c4512a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/instrumentationClientInject", "page_title": "next.config.js: instrumentationClientInject | Next.js", "page_type": "api", "page_summary": "This page documents the `instrumentationClientInject` option in `next.config.js`, which allows plugins to inject client-side instrumentation modules that run before the user's…", "heading": "Version history", "content": "Page: next.config.js: instrumentationClientInject | Next.js\nSection: Version history\n\n| Version | Changes |\n| --- | --- |\n| `v16.3.0` | `instrumentationClientInject` introduced |", "code_blocks": [], "chunk_position": 54, "heading_path": "Version history > Version history", "breadcrumbs": "next.config.js: instrumentationClientInject | Next.js > Version history > Version history"}, {"id": "8e7c3052508400a5", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/logging", "page_title": "next.config.js: logging", "page_type": "api", "page_summary": "Configuration options for logging in Next.js, including fetch logging, server functions, incoming requests, browser console logs, and disabling logging.", "heading": "Fetching", "content": "Page: next.config.js: logging\nSection: Fetching\n\nYou can configure the logging level and whether the full URL is logged to the console when running Next.js in development mode.\n\nAny `fetch` requests that are restored from the [Server Components HMR…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  logging: {\n    fetches: {\n      fullUrl: true,\n    },\n  },\n}", "filename": ""}, {"language": "javascript", "code": "module.exports = {\n  logging: {\n    fetches: {\n      hmrRefreshes: true,\n    },\n  },\n}", "filename": ""}], "chunk_position": 55, "heading_path": "Fetching > Fetching", "breadcrumbs": "next.config.js: logging > Fetching > Fetching"}, {"id": "97e81b1398bce2c2", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/logging", "page_title": "next.config.js: logging", "page_type": "api", "page_summary": "Configuration options for logging in Next.js, including fetch logging, server functions, incoming requests, browser console logs, and disabling logging.", "heading": "Server Functions", "content": "Page: next.config.js: logging\nSection: Server Functions\n\n[Server Function](https://react.dev/reference/rsc/server-functions) invocations are logged by default during development. You can disable this by setting `logging.serverFunctions` to `false`.\n\nWhen…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  logging: {\n    serverFunctions: false,\n  },\n}", "filename": ""}, {"language": "terminal", "code": "POST /\n  └─ ƒ myAction(arg1, arg2) in 5ms app/actions.ts", "filename": ""}], "chunk_position": 55, "heading_path": "Server Functions > Server Functions", "breadcrumbs": "next.config.js: logging > Server Functions > Server Functions"}, {"id": "a7762524e55710ce", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/logging", "page_title": "next.config.js: logging", "page_type": "api", "page_summary": "Configuration options for logging in Next.js, including fetch logging, server functions, incoming requests, browser console logs, and disabling logging.", "heading": "Incoming Requests", "content": "Page: next.config.js: logging\nSection: Incoming Requests\n\nBy default all the incoming requests will be logged in the console during development. You can use the `incomingRequests` option to decide which requests to ignore.\nSince this is only logged in…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  logging: {\n    incomingRequests: {\n      ignore: [/\\api\\/v1\\/health/],\n    },\n  },\n}", "filename": ""}, {"language": "javascript", "code": "module.exports = {\n  logging: {\n    incomingRequests: false,\n  },\n}", "filename": ""}], "chunk_position": 55, "heading_path": "Incoming Requests > Incoming Requests", "breadcrumbs": "next.config.js: logging > Incoming Requests > Incoming Requests"}, {"id": "f6eb72e439fbb968", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/logging", "page_title": "next.config.js: logging", "page_type": "api", "page_summary": "Configuration options for logging in Next.js, including fetch logging, server functions, incoming requests, browser console logs, and disabling logging.", "heading": "Browser Console Logs", "content": "Page: next.config.js: logging\nSection: Browser Console Logs\n\nYou can forward browser console logs (such as `console.log`, `console.warn`, `console.error`) to the terminal during development. This is useful for debugging client-side code without needing to…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  logging: {\n    browserToTerminal: true,\n  },\n}", "filename": ""}], "chunk_position": 55, "heading_path": "Browser Console Logs > Browser Console Logs", "breadcrumbs": "next.config.js: logging > Browser Console Logs > Browser Console Logs"}, {"id": "2a8f615d7e382348", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/logging", "page_title": "next.config.js: logging", "page_type": "api", "page_summary": "Configuration options for logging in Next.js, including fetch logging, server functions, incoming requests, browser console logs, and disabling logging.", "heading": "Source Location", "content": "Page: next.config.js: logging\nSection: Source Location\n\nWhen enabled, browser logs include source location information (file path and line number) by default. For example:", "code_blocks": [{"language": "tsx", "code": "'use client'\n \nexport default function Home() {\n  return (\n    <button\n      type=\"button\"\n      onClick={() => {\n        console.log('Hello World')\n      }}\n    >\n      Click me\n    </button>\n  )\n}", "filename": ""}, {"language": "terminal", "code": "[browser] Hello World (app/page.tsx:8:17)", "filename": ""}], "chunk_position": 55, "heading_path": "Source Location > Source Location", "breadcrumbs": "next.config.js: logging > Source Location > Source Location"}, {"id": "5850cd065b7172c0", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/logging", "page_title": "next.config.js: logging", "page_type": "api", "page_summary": "Configuration options for logging in Next.js, including fetch logging, server functions, incoming requests, browser console logs, and disabling logging.", "heading": "Disabling Logging", "content": "Page: next.config.js: logging\nSection: Disabling Logging\n\nIn addition, you can disable the development logging by setting `logging` to `false`.", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  logging: false,\n}", "filename": ""}], "chunk_position": 55, "heading_path": "Disabling Logging > Disabling Logging", "breadcrumbs": "next.config.js: logging > Disabling Logging > Disabling Logging"}, {"id": "1d79b58863fcce25", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/logging", "page_title": "next.config.js: logging", "page_type": "api", "page_summary": "Configuration options for logging in Next.js, including fetch logging, server functions, incoming requests, browser console logs, and disabling logging.", "heading": "Version History", "content": "Page: next.config.js: logging\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v16.2.0` | `browserToTerminal` added (moved from `experimental.browserDebugInfoInTerminal`) |\n| `v15.4.0` | `experimental.browserDebugInfoInTerminal` introduced…", "code_blocks": [], "chunk_position": 55, "heading_path": "Version History > Version History", "breadcrumbs": "next.config.js: logging > Version History > Version History"}, {"id": "722b9876c2da548d", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/mdxRs", "page_title": "mdxRs", "page_type": "reference", "page_summary": "Explains the experimental `mdxRs` config option in Next.js, which enables the Rust compiler for MDX files when used with `@next/mdx`.", "heading": "mdxRs", "content": "Page: mdxRs\nSection: mdxRs\n\nFor experimental use with `@next/mdx`. Compiles MDX files using the new Rust compiler.\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out…", "code_blocks": [{"language": "javascript", "code": "const withMDX = require('@next/mdx')()\n \n/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  pageExtensions: ['ts', 'tsx', 'mdx'],\n  experimental: {\n    mdxRs: true,\n  },\n}…", "filename": "next.config.js"}], "chunk_position": 56, "heading_path": "mdxRs > mdxRs", "breadcrumbs": "mdxRs > mdxRs > mdxRs"}, {"id": "90666884eacf754d", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/onDemandEntries", "page_title": "next.config.js: onDemandEntries | Next.js", "page_type": "api", "page_summary": "Explains the onDemandEntries configuration option in next.config.js, which controls how the development server keeps built pages in memory.", "heading": "onDemandEntries", "content": "Page: next.config.js: onDemandEntries | Next.js\nSection: onDemandEntries\n\nNext.js exposes some options that give you some control over how the server will dispose or keep in memory built pages in development.\n\nTo change the defaults, open `next.config.js` and add the…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  onDemandEntries: {\n    // period (in ms) where the server will keep pages in the buffer\n    maxInactiveAge: 25 * 1000,\n    // number of pages that should be kept simultaneously…", "filename": "next.config.js"}], "chunk_position": 57, "heading_path": "onDemandEntries > onDemandEntries", "breadcrumbs": "next.config.js: onDemandEntries | Next.js > onDemandEntries > onDemandEntries"}, {"id": "dd5d23d6ac4523bd", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/optimizePackageImports", "page_title": "optimizePackageImports", "page_type": "api", "page_summary": "Describes the experimental `optimizePackageImports` option in next.config.js, which optimizes package imports by only loading the modules actually used, and lists the libraries optimized by default.", "heading": "optimizePackageImports", "content": "Page: optimizePackageImports\nSection: optimizePackageImports\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on GitHub.\n\nSome packages can export hundreds or thousands of…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  experimental: {\n    optimizePackageImports: ['package-name'],\n  },\n}", "filename": "next.config.js"}], "chunk_position": 58, "heading_path": "optimizePackageImports > optimizePackageImports", "breadcrumbs": "optimizePackageImports > optimizePackageImports > optimizePackageImports"}, {"id": "58ab026467942427", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/output", "page_title": "next.config.js: output | Next.js", "page_type": "reference", "page_summary": "This page documents the `output` option in `next.config.js`, which enables Next.js to trace page dependencies during builds and optionally create a standalone folder containing only the necessary…", "heading": "output", "content": "Page: next.config.js: output | Next.js\nSection: output\n\nDuring a build, Next.js will automatically trace each page and its dependencies to determine all of the files that are needed for deploying a production version of your application.\n\nThis feature…", "code_blocks": [], "chunk_position": 59, "heading_path": "output > output", "breadcrumbs": "next.config.js: output | Next.js > output > output"}, {"id": "a3eb2f37a001ac26", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/output", "page_title": "next.config.js: output | Next.js", "page_type": "reference", "page_summary": "This page documents the `output` option in `next.config.js`, which enables Next.js to trace page dependencies during builds and optionally create a standalone folder containing only the necessary…", "heading": "How it Works", "content": "Page: next.config.js: output | Next.js\nSection: How it Works\n\nDuring `next build`, Next.js will use [`@vercel/nft`](https://github.com/vercel/nft) to statically analyze `import`, `require`, and `fs` usage to determine all files that a page might load.\n\nNext.js'…", "code_blocks": [], "chunk_position": 59, "heading_path": "How it Works > How it Works", "breadcrumbs": "next.config.js: output | Next.js > How it Works > How it Works"}, {"id": "e9686a771a092f88", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/output", "page_title": "next.config.js: output | Next.js", "page_type": "reference", "page_summary": "This page documents the `output` option in `next.config.js`, which enables Next.js to trace page dependencies during builds and optionally create a standalone folder containing only the necessary…", "heading": "Automatically Copying Traced Files", "content": "Page: next.config.js: output | Next.js\nSection: Automatically Copying Traced Files\n\nNext.js can automatically create a `standalone` folder that copies only the necessary files for a production deployment including select files in `node_modules`.\n\nTo leverage this automatic copying…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  output: 'standalone',\n}", "filename": "next.config.js"}, {"language": "Terminal", "code": "cp -r public .next/standalone/ && cp -r .next/static .next/standalone/.next/", "filename": ""}, {"language": "Terminal", "code": "node .next/standalone/server.js", "filename": ""}], "chunk_position": 59, "heading_path": "Automatically Copying Traced Files > Automatically Copying Traced Files", "breadcrumbs": "next.config.js: output | Next.js > Automatically Copying Traced Files > Automatically Copying Traced Files"}, {"id": "d9bd762d618b26ef", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/output", "page_title": "next.config.js: output | Next.js", "page_type": "reference", "page_summary": "This page documents the `output` option in `next.config.js`, which enables Next.js to trace page dependencies during builds and optionally create a standalone folder containing only the necessary…", "heading": "Caveats", "content": "Page: next.config.js: output | Next.js\nSection: Caveats\n\nWhile tracing in monorepo setups, the project directory is used for tracing by default. For `next build packages/web-app`, `packages/web-app` would be the tracing root and any files outside of that…", "code_blocks": [{"language": "javascript", "code": "const path = require('path')\n \nmodule.exports = {\n  // this includes files from the monorepo base two directories up\n  outputFileTracingRoot: path.join(__dirname, '../../'),\n}", "filename": "packages/web-app/next.config.js"}, {"language": "javascript", "code": "module.exports = {\n  outputFileTracingExcludes: {\n    '/api/hello': ['./un-necessary-folder/**/*'],\n  },\n  outputFileTracingIncludes: {\n    '/api/another': ['./necessary-folder/**/*'],…", "filename": "next.config.js"}, {"language": "javascript", "code": "module.exports = {\n  outputFileTracingIncludes: {\n    '/products/*': ['src/lib/payments/**/*'],\n    '/*': ['src/config/runtime/**/*.json'],\n  },\n  outputFileTracingExcludes: {\n    '/api/*':…", "filename": "next.config.js"}, {"language": "javascript", "code": "module.exports = {\n  outputFileTracingIncludes: {\n    '/*': ['src/i18n/locales/**/*.json'],\n  },\n}", "filename": "next.config.js"}, {"language": "javascript", "code": "const path = require('path')\n \nmodule.exports = {\n  // Trace from the monorepo root\n  outputFileTracingRoot: path.join(__dirname, '../../'),\n  outputFileTracingIncludes: {\n    '/route1':…", "filename": "next.config.js"}, {"language": "javascript", "code": "module.exports = {\n  outputFileTracingIncludes: {\n    '/*': ['node_modules/sharp/**/*', 'node_modules/aws-crt/dist/bin/**/*'],\n  },\n}", "filename": "next.config.js"}], "chunk_position": 59, "heading_path": "Caveats > Caveats", "breadcrumbs": "next.config.js: output | Next.js > Caveats > Caveats"}, {"id": "511cb45cea919008", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/outputHashSalt", "page_title": "outputHashSalt", "page_type": "reference", "page_summary": "This page documents the `outputHashSalt` option in Next.js configuration, which adds a salt string to output filenames to invalidate cached assets across deployments.", "heading": "Overview", "content": "Page: outputHashSalt\nSection: Overview\n\n`outputHashSalt` is an option that incorporates a configurable salt string into every content-addressed output filename (chunks, assets). Changing this value forces all output hashes to change, which…", "code_blocks": [], "chunk_position": 60, "heading_path": "Overview > Overview", "breadcrumbs": "outputHashSalt > Overview > Overview"}, {"id": "cafd2fef31d6ae09", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/outputHashSalt", "page_title": "outputHashSalt", "page_type": "reference", "page_summary": "This page documents the `outputHashSalt` option in Next.js configuration, which adds a salt string to output filenames to invalidate cached assets across deployments.", "heading": "Configuration", "content": "Page: outputHashSalt\nSection: Configuration\n\nTo configure the output hash salt, set `outputHashSalt` in `next.config.js`:", "code_blocks": [{"language": "javascript", "code": "/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  outputHashSalt: 'my-deployment-salt',\n}\n \nmodule.exports = nextConfig", "filename": "next.config.js"}], "chunk_position": 60, "heading_path": "Configuration > Configuration", "breadcrumbs": "outputHashSalt > Configuration > Configuration"}, {"id": "23925ba39e8ebb5f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/outputHashSalt", "page_title": "outputHashSalt", "page_type": "reference", "page_summary": "This page documents the `outputHashSalt` option in Next.js configuration, which adds a salt string to output filenames to invalidate cached assets across deployments.", "heading": "Bundler Support", "content": "Page: outputHashSalt\nSection: Bundler Support\n\nThis works with both Webpack and Turbopack bundlers.", "code_blocks": [], "chunk_position": 60, "heading_path": "Bundler Support > Bundler Support", "breadcrumbs": "outputHashSalt > Bundler Support > Bundler Support"}, {"id": "2813d8ae97d46109", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/outputHashSalt", "page_title": "outputHashSalt", "page_type": "reference", "page_summary": "This page documents the `outputHashSalt` option in Next.js configuration, which adds a salt string to output filenames to invalidate cached assets across deployments.", "heading": "Environment Variable", "content": "Page: outputHashSalt\nSection: Environment Variable\n\nThe `NEXT_HASH_SALT` environment variable can also be used for the same purpose. When both are set, the values are **concatenated** (`outputHashSalt + NEXT_HASH_SALT`) to form the effective salt.…", "code_blocks": [{"language": "bash", "code": "NEXT_HASH_SALT=my-deployment-salt next build", "filename": ""}], "chunk_position": 60, "heading_path": "Environment Variable > Environment Variable", "breadcrumbs": "outputHashSalt > Environment Variable > Environment Variable"}, {"id": "666e34f86506b64f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/pageExtensions", "page_title": "next.config.js: pageExtensions | Next.js", "page_type": "api", "page_summary": "Reference for the pageExtensions option in next.config.js, which customizes which file extensions Next.js treats as pages—for example, to support Markdown and MDX.", "heading": "pageExtensions", "content": "Page: next.config.js: pageExtensions | Next.js\nSection: pageExtensions\n\nBy default, Next.js accepts files with the following extensions: `.tsx`, `.ts`, `.jsx`, `.js`. This can be modified to allow other extensions like markdown (`.md`, `.mdx`).", "code_blocks": [{"language": "javascript", "code": "const withMDX = require('@next/mdx')()\n \n/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],\n}\n \nmodule.exports =…", "filename": "next.config.js"}], "chunk_position": 61, "heading_path": "pageExtensions > pageExtensions", "breadcrumbs": "next.config.js: pageExtensions | Next.js > pageExtensions > pageExtensions"}, {"id": "65d8c61abf3c029d", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/partialPrefetching", "page_title": "partialPrefetching", "page_type": "api", "page_summary": "Configuration option for Next.js that enables Partial Prefetching at the app level, allowing the framework to prefetch reusable App Shells per route instead of per link.", "heading": "Usage", "content": "Page: partialPrefetching\nSection: Usage\n\n`partialPrefetching` requires [`cacheComponents`](/docs/app/api-reference/config/next-config-js/cacheComponents). Without it, `next dev` and `next build` throw at config validation.", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  cacheComponents: true,\n  partialPrefetching: true,\n}\n \nexport default nextConfig", "filename": ""}], "chunk_position": 62, "heading_path": "Usage > Usage", "breadcrumbs": "partialPrefetching > Usage > Usage"}, {"id": "5aa551f1395db35a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/partialPrefetching", "page_title": "partialPrefetching", "page_type": "api", "page_summary": "Configuration option for Next.js that enables Partial Prefetching at the app level, allowing the framework to prefetch reusable App Shells per route instead of per link.", "heading": "Reference", "content": "Page: partialPrefetching\nSection: Reference\n\n| Value | Description |\n| --- | --- |\n| `true` | Enables Partial Prefetching across the app. |\n| `false` | Default. No change to prefetch behavior. |", "code_blocks": [], "chunk_position": 62, "heading_path": "Reference > Reference", "breadcrumbs": "partialPrefetching > Reference > Reference"}, {"id": "bd42852c08c7678f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/partialPrefetching", "page_title": "partialPrefetching", "page_type": "api", "page_summary": "Configuration option for Next.js that enables Partial Prefetching at the app level, allowing the framework to prefetch reusable App Shells per route instead of per link.", "heading": "How prefetches resolve", "content": "Page: partialPrefetching\nSection: How prefetches resolve\n\nBefore Partial Prefetching, Next.js prefetched per visible link: a page with N links to N routes produced ~N route prefetches as those links entered the viewport.\n\nWith `partialPrefetching: true`,…", "code_blocks": [], "chunk_position": 62, "heading_path": "How prefetches resolve > How prefetches resolve", "breadcrumbs": "partialPrefetching > How prefetches resolve > How prefetches resolve"}, {"id": "be798832d1b28c52", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/partialPrefetching", "page_title": "partialPrefetching", "page_type": "api", "page_summary": "Configuration option for Next.js that enables Partial Prefetching at the app level, allowing the framework to prefetch reusable App Shells per route instead of per link.", "heading": "Per-segment overrides", "content": "Page: partialPrefetching\nSection: Per-segment overrides\n\nA segment that exports an explicit [`prefetch`](/docs/app/api-reference/file-conventions/route-segment-config/prefetch) value overrides the app-level default for that route.", "code_blocks": [], "chunk_position": 62, "heading_path": "Per-segment overrides > Per-segment overrides", "breadcrumbs": "partialPrefetching > Per-segment overrides > Per-segment overrides"}, {"id": "5c6bb1b2341ed7cf", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/partialPrefetching", "page_title": "partialPrefetching", "page_type": "api", "page_summary": "Configuration option for Next.js that enables Partial Prefetching at the app level, allowing the framework to prefetch reusable App Shells per route instead of per link.", "heading": "Version History", "content": "Page: partialPrefetching\nSection: Version History\n\n| Version | Change |\n| --- | --- |\n| 16.3.0 | `partialPrefetching` introduced. Requires `cacheComponents` to be enabled. |", "code_blocks": [], "chunk_position": 62, "heading_path": "Version History > Version History", "breadcrumbs": "partialPrefetching > Version History > Version History"}, {"id": "8504ee3312546b77", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/partialPrefetching", "page_title": "partialPrefetching", "page_type": "api", "page_summary": "Configuration option for Next.js that enables Partial Prefetching at the app level, allowing the framework to prefetch reusable App Shells per route instead of per link.", "heading": "Related", "content": "Page: partialPrefetching\nSection: Related\n\nView related API references and guides.\n- [cacheComponents - Learn how to enable the cacheComponents flag in Next.js.](/docs/app/api-reference/config/next-config-js/cacheComponents)\n- [prefetch - API…", "code_blocks": [], "chunk_position": 62, "heading_path": "Related > Related", "breadcrumbs": "partialPrefetching > Related > Related"}, {"id": "f81d9b2728e2ebb1", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/poweredByHeader", "page_title": "next.config.js: poweredByHeader", "page_type": "reference", "page_summary": "Explains how to disable the `x-powered-by` header in Next.js by setting `poweredByHeader: false` in `next.config.js`.", "heading": "poweredByHeader", "content": "Page: next.config.js: poweredByHeader\nSection: poweredByHeader\n\nBy default Next.js will add the `x-powered-by` header. To opt-out of it, open `next.config.js` and disable the `poweredByHeader` config:", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  poweredByHeader: false,\n}", "filename": "next.config.js"}], "chunk_position": 63, "heading_path": "poweredByHeader > poweredByHeader", "breadcrumbs": "next.config.js: poweredByHeader > poweredByHeader > poweredByHeader"}, {"id": "4a45cbd28691236b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/prefetchInlining", "page_title": "prefetchInlining", "page_type": "api", "page_summary": "Describe the experimental `prefetchInlining` configuration option in Next.js, which controls whether App Router prefetch responses are bundled into a single response, and how to disable or customize…", "heading": "prefetchInlining", "content": "Page: prefetchInlining\nSection: prefetchInlining\n\nWhen the App Router prefetches a route, it can bundle small segment responses into a single response instead of requesting each one separately. This reduces the number of prefetch requests at the…", "code_blocks": [], "chunk_position": 64, "heading_path": "prefetchInlining > prefetchInlining", "breadcrumbs": "prefetchInlining > prefetchInlining > prefetchInlining"}, {"id": "a6bb867a3ea5fb93", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/prefetchInlining", "page_title": "prefetchInlining", "page_type": "api", "page_summary": "Describe the experimental `prefetchInlining` configuration option in Next.js, which controls whether App Router prefetch responses are bundled into a single response, and how to disable or customize…", "heading": "Usage", "content": "Page: prefetchInlining\nSection: Usage\n\nTo turn off prefetch inlining, set `experimental.prefetchInlining` to `false`:\n\nTo override the thresholds instead of disabling inlining, pass an object. Any value you omit keeps its default:", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    prefetchInlining: false,\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}, {"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    prefetchInlining: {\n      maxSize: 2048,\n      maxBundleSize: 10240,\n    },\n  },\n}\n \nexport default…", "filename": "next.config.ts"}], "chunk_position": 64, "heading_path": "Usage > Usage", "breadcrumbs": "prefetchInlining > Usage > Usage"}, {"id": "d492c1b8ce9d8339", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/prefetchInlining", "page_title": "prefetchInlining", "page_type": "api", "page_summary": "Describe the experimental `prefetchInlining` configuration option in Next.js, which controls whether App Router prefetch responses are bundled into a single response, and how to disable or customize…", "heading": "Reference", "content": "Page: prefetchInlining\nSection: Reference\n\n| Value | Description |\n| --- | --- |\n| `true` | Inlines prefetch responses with the default thresholds. This is the default. |\n| `false` | Disables prefetch inlining. Each segment is prefetched as…", "code_blocks": [], "chunk_position": 64, "heading_path": "Reference > Reference", "breadcrumbs": "prefetchInlining > Reference > Reference"}, {"id": "dcf4bef654499af9", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/prefetchInlining", "page_title": "prefetchInlining", "page_type": "api", "page_summary": "Describe the experimental `prefetchInlining` configuration option in Next.js, which controls whether App Router prefetch responses are bundled into a single response, and how to disable or customize…", "heading": "Version History", "content": "Page: prefetchInlining\nSection: Version History\n\n| Version | Change |\n| --- | --- |\n| 16.3.0 | `experimental.prefetchInlining` enabled by default. |\n| 16.2.0 | `experimental.prefetchInlining` added. |", "code_blocks": [], "chunk_position": 64, "heading_path": "Version History > Version History", "breadcrumbs": "prefetchInlining > Version History > Version History"}, {"id": "986783182e2da78a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/prefetchInlining", "page_title": "prefetchInlining", "page_type": "api", "page_summary": "Describe the experimental `prefetchInlining` configuration option in Next.js, which controls whether App Router prefetch responses are bundled into a single response, and how to disable or customize…", "heading": "Related", "content": "Page: prefetchInlining\nSection: Related\n\nView related API references and guides.\n\n[Link Component](/docs/app/api-reference/components/link) — Enable fast client-side navigation with the built-in `next/link`…", "code_blocks": [], "chunk_position": 64, "heading_path": "Related > Related", "breadcrumbs": "prefetchInlining > Related > Related"}, {"id": "c304ddf5e2c385bf", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/productionBrowserSourceMaps", "page_title": "productionBrowserSourceMaps", "page_type": "api", "page_summary": "Explains how to enable browser source map generation during production builds in Next.js using the productionBrowserSourceMaps configuration flag.", "heading": "productionBrowserSourceMaps", "content": "Page: productionBrowserSourceMaps\nSection: productionBrowserSourceMaps\n\nSource Maps are enabled by default during development. During production builds, they are disabled to prevent you leaking your source on the client, unless you specifically opt-in with the…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  productionBrowserSourceMaps: true,\n}", "filename": "next.config.js"}], "chunk_position": 65, "heading_path": "productionBrowserSourceMaps > productionBrowserSourceMaps", "breadcrumbs": "productionBrowserSourceMaps > productionBrowserSourceMaps > productionBrowserSourceMaps"}, {"id": "423736aa7074cfdd", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/proxyClientMaxBodySize", "page_title": "next.config.js: proxyClientMaxBodySize", "page_type": "api", "page_summary": "Configuration option to set a size limit on the buffered request body when using proxy in Next.js, preventing excessive memory usage. Defaults to 10MB.", "heading": "Introduction", "content": "Page: next.config.js: proxyClientMaxBodySize\nSection: Introduction\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on GitHub. Last updated October 20, 2025\n\nWhen proxy is used,…", "code_blocks": [], "chunk_position": 66, "heading_path": "Introduction > Introduction", "breadcrumbs": "next.config.js: proxyClientMaxBodySize > Introduction > Introduction"}, {"id": "2135aa159d619d53", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/proxyClientMaxBodySize", "page_title": "next.config.js: proxyClientMaxBodySize", "page_type": "api", "page_summary": "Configuration option to set a size limit on the buffered request body when using proxy in Next.js, preventing excessive memory usage. Defaults to 10MB.", "heading": "String format (recommended)", "content": "Page: next.config.js: proxyClientMaxBodySize\nSection: String format (recommended)\n\nSpecify the size using a human-readable string format:\n\nSupported units: b, kb, mb, gb", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    proxyClientMaxBodySize: '1mb',\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 66, "heading_path": "String format (recommended) > String format (recommended)", "breadcrumbs": "next.config.js: proxyClientMaxBodySize > String format (recommended) > String format (recommended)"}, {"id": "3ab0049d5ba4ee94", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/proxyClientMaxBodySize", "page_title": "next.config.js: proxyClientMaxBodySize", "page_type": "api", "page_summary": "Configuration option to set a size limit on the buffered request body when using proxy in Next.js, preventing excessive memory usage. Defaults to 10MB.", "heading": "Number format", "content": "Page: next.config.js: proxyClientMaxBodySize\nSection: Number format\n\nAlternatively, specify the size in bytes as a number:", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    proxyClientMaxBodySize: 1048576, // 1MB in bytes\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 66, "heading_path": "Number format > Number format", "breadcrumbs": "next.config.js: proxyClientMaxBodySize > Number format > Number format"}, {"id": "6a4255c187403945", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/proxyClientMaxBodySize", "page_title": "next.config.js: proxyClientMaxBodySize", "page_type": "api", "page_summary": "Configuration option to set a size limit on the buffered request body when using proxy in Next.js, preventing excessive memory usage. Defaults to 10MB.", "heading": "Behavior", "content": "Page: next.config.js: proxyClientMaxBodySize\nSection: Behavior\n\nWhen a request body exceeds the configured limit:\n\n- Next.js will buffer only the first N bytes (up to the limit)\n- A warning will be logged to the console indicating the route that exceeded the…", "code_blocks": [], "chunk_position": 66, "heading_path": "Behavior > Behavior", "breadcrumbs": "next.config.js: proxyClientMaxBodySize > Behavior > Behavior"}, {"id": "02c1d3234c191197", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/proxyClientMaxBodySize", "page_title": "next.config.js: proxyClientMaxBodySize", "page_type": "api", "page_summary": "Configuration option to set a size limit on the buffered request body when using proxy in Next.js, preventing excessive memory usage. Defaults to 10MB.", "heading": "Example", "content": "Page: next.config.js: proxyClientMaxBodySize\nSection: Example\n\n```typescript\nimport { NextRequest, NextResponse } from 'next/server'\n \nexport async function proxy(request: NextRequest) {\n  // Next.js automatically buffers the body with the configured size limit\n  // You can…\n```\n\n```typescript\nimport { NextRequest, NextResponse } from 'next/server'\n \nexport async function POST(request: NextRequest) {\n  // ...and the body is still available in your route handler\n  const body = await…\n```", "code_blocks": [{"language": "typescript", "code": "import { NextRequest, NextResponse } from 'next/server'\n \nexport async function proxy(request: NextRequest) {\n  // Next.js automatically buffers the body with the configured size limit\n  // You can…", "filename": "proxy.ts"}, {"language": "typescript", "code": "import { NextRequest, NextResponse } from 'next/server'\n \nexport async function POST(request: NextRequest) {\n  // ...and the body is still available in your route handler\n  const body = await…", "filename": "app/api/upload/route.ts"}], "chunk_position": 66, "heading_path": "Example > Example", "breadcrumbs": "next.config.js: proxyClientMaxBodySize > Example > Example"}, {"id": "5cb55efce1752bb5", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/proxyClientMaxBodySize", "page_title": "next.config.js: proxyClientMaxBodySize", "page_type": "api", "page_summary": "Configuration option to set a size limit on the buffered request body when using proxy in Next.js, preventing excessive memory usage. Defaults to 10MB.", "heading": "Good to know", "content": "Page: next.config.js: proxyClientMaxBodySize\nSection: Good to know\n\n- This setting only applies when proxy is used in your application\n- The default limit of 10MB is designed to balance memory usage and typical use cases\n- The limit applies per-request, not globally…", "code_blocks": [], "chunk_position": 66, "heading_path": "Good to know > Good to know", "breadcrumbs": "next.config.js: proxyClientMaxBodySize > Good to know > Good to know"}, {"id": "f9d7500f73dfe276", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/reactCompiler", "page_title": "reactCompiler", "page_type": "api", "page_summary": "This page documents the `reactCompiler` configuration option in Next.js, which enables the React Compiler to automatically optimize component rendering, reducing the need for manual memoization.", "heading": "How It Works", "content": "Page: reactCompiler\nSection: How It Works\n\nThe React Compiler runs through a Babel plugin. To keep builds fast, Next.js uses a custom SWC optimization that only applies the React Compiler to relevant files—like those with JSX or React…", "code_blocks": [{"language": "bash", "code": "pnpm add -D babel-plugin-react-compiler", "filename": ""}, {"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  reactCompiler: true,\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 67, "heading_path": "How It Works > How It Works", "breadcrumbs": "reactCompiler > How It Works > How It Works"}, {"id": "1605a3c10811ae2b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/reactCompiler", "page_title": "reactCompiler", "page_type": "api", "page_summary": "This page documents the `reactCompiler` configuration option in Next.js, which enables the React Compiler to automatically optimize component rendering, reducing the need for manual memoization.", "heading": "Annotations", "content": "Page: reactCompiler\nSection: Annotations\n\nYou can configure the compiler to run in \"opt-in\" mode as follows:\n\nThen, you can annotate specific components or hooks with the `\"use memo\"` directive from React to opt-in:\n\n> **Note:**  You can…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  reactCompiler: {\n    compilationMode: 'annotation',\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}, {"language": "typescript", "code": "export default function Page() {\n  'use memo'\n  // ...\n}", "filename": "app/page.tsx"}], "chunk_position": 67, "heading_path": "Annotations > Annotations", "breadcrumbs": "reactCompiler > Annotations > Annotations"}, {"id": "ae01bdbcea699d40", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/reactMaxHeadersLength", "page_title": "reactMaxHeadersLength", "page_type": "api", "page_summary": "This page describes the `reactMaxHeadersLength` option in `next.config.js`, which controls the maximum length of headers emitted by React during prerendering, with a default value of 6000.", "heading": "reactMaxHeadersLength", "content": "Page: reactMaxHeadersLength\nSection: reactMaxHeadersLength\n\nDuring prerendering, React can emit headers that can be added to the response. These can be used to improve performance by allowing the browser to preload resources like fonts, scripts, and…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  reactMaxHeadersLength: 1000,\n}", "filename": "next.config.js"}], "chunk_position": 68, "heading_path": "reactMaxHeadersLength > reactMaxHeadersLength", "breadcrumbs": "reactMaxHeadersLength > reactMaxHeadersLength > reactMaxHeadersLength"}, {"id": "3d9cba5ca117134f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/reactStrictMode", "page_title": "next.config.js: reactStrictMode | Next.js", "page_type": "reference", "page_summary": "This page documents the reactStrictMode configuration option in next.config.js, which enables React Strict Mode in Next.js applications, with notes on default behavior and migration options.", "heading": "reactStrictMode", "content": "Page: next.config.js: reactStrictMode | Next.js\nSection: reactStrictMode\n\nGood to know: Since Next.js 13.5.1, Strict Mode is true by default with app router, so the above configuration is only necessary for pages. You can still disable Strict Mode by setting…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  reactStrictMode: true,\n}", "filename": "next.config.js"}], "chunk_position": 69, "heading_path": "reactStrictMode > reactStrictMode", "breadcrumbs": "next.config.js: reactStrictMode | Next.js > reactStrictMode > reactStrictMode"}, {"id": "b3ede6aed911c141", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects", "page_title": "next.config.js: redirects | Next.js", "page_type": "reference", "page_summary": "Documentation for the `redirects` key in `next.config.js`, which allows redirecting incoming request paths to different destination paths, including path matching, header/cookie/query matching,…", "heading": "redirects", "content": "Page: next.config.js: redirects | Next.js\nSection: redirects\n\nRedirects allow you to redirect an incoming request path to a different destination path.\n\nTo use redirects you can use the `redirects` key in `next.config.js`:\n\n`redirects` can be defined as a…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  redirects() {\n    return [\n      {\n        source: '/about',\n        destination: '/',\n        permanent: true,\n      },\n    ]\n  },\n}", "filename": "next.config.js"}, {"language": "js", "code": "{\n  source: '/old-blog/:path*',\n  destination: '/blog/:path*',\n  permanent: false\n}", "filename": ""}], "chunk_position": 70, "heading_path": "redirects > redirects", "breadcrumbs": "next.config.js: redirects | Next.js > redirects > redirects"}, {"id": "b43a0588219cb520", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects", "page_title": "next.config.js: redirects | Next.js", "page_type": "reference", "page_summary": "Documentation for the `redirects` key in `next.config.js`, which allows redirecting incoming request paths to different destination paths, including path matching, header/cookie/query matching,…", "heading": "Path Matching", "content": "Page: next.config.js: redirects | Next.js\nSection: Path Matching\n\nPath matches are allowed, for example `/old-blog/:slug` will match `/old-blog/first-post` (no nested paths):\n\nThe pattern `/old-blog/:slug` matches `/old-blog/first-post` and `/old-blog/post-1` but…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  redirects() {\n    return [\n      {\n        source: '/old-blog/:slug',\n        destination: '/news/:slug', // Matched parameters can be used in the destination\n        permanent:…", "filename": "next.config.js"}], "chunk_position": 70, "heading_path": "Path Matching > Path Matching", "breadcrumbs": "next.config.js: redirects | Next.js > Path Matching > Path Matching"}, {"id": "3547a054e3635730", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects", "page_title": "next.config.js: redirects | Next.js", "page_type": "reference", "page_summary": "Documentation for the `redirects` key in `next.config.js`, which allows redirecting incoming request paths to different destination paths, including path matching, header/cookie/query matching,…", "heading": "Wildcard Path Matching", "content": "Page: next.config.js: redirects | Next.js\nSection: Wildcard Path Matching\n\nTo match a wildcard path you can use `*` after a parameter, for example `/blog/:slug*` will match `/blog/a/b/c/d/hello-world`:", "code_blocks": [{"language": "js", "code": "module.exports = {\n  redirects() {\n    return [\n      {\n        source: '/blog/:slug*',\n        destination: '/news/:slug*', // Matched parameters can be used in the destination\n        permanent:…", "filename": "next.config.js"}], "chunk_position": 70, "heading_path": "Wildcard Path Matching > Wildcard Path Matching", "breadcrumbs": "next.config.js: redirects | Next.js > Wildcard Path Matching > Wildcard Path Matching"}, {"id": "1f41d3592e2cb35a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects", "page_title": "next.config.js: redirects | Next.js", "page_type": "reference", "page_summary": "Documentation for the `redirects` key in `next.config.js`, which allows redirecting incoming request paths to different destination paths, including path matching, header/cookie/query matching,…", "heading": "Regex Path Matching", "content": "Page: next.config.js: redirects | Next.js\nSection: Regex Path Matching\n\nTo match a regex path you can wrap the regex in parentheses after a parameter, for example `/post/:slug(\\d{1,})` will match `/post/123` but not `/post/abc`:\n\nThe following characters `(`, `)`, `{`,…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  redirects() {\n    return [\n      {\n        source: '/post/:slug(\\\\d{1,})',\n        destination: '/news/:slug', // Matched parameters can be used in the destination…", "filename": "next.config.js"}, {"language": "js", "code": "module.exports = {\n  redirects() {\n    return [\n      {\n        // this will match `/english(default)/something` being requested\n        source: '/english\\\\(default\\\\)/:slug',\n        destination:…", "filename": "next.config.js"}], "chunk_position": 70, "heading_path": "Regex Path Matching > Regex Path Matching", "breadcrumbs": "next.config.js: redirects | Next.js > Regex Path Matching > Regex Path Matching"}, {"id": "fc0107c141c95b9a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects", "page_title": "next.config.js: redirects | Next.js", "page_type": "reference", "page_summary": "Documentation for the `redirects` key in `next.config.js`, which allows redirecting incoming request paths to different destination paths, including path matching, header/cookie/query matching,…", "heading": "Header, Cookie, and Query Matching", "content": "Page: next.config.js: redirects | Next.js\nSection: Header, Cookie, and Query Matching\n\nTo only match a redirect when header, cookie, or query values also match the `has` field or don't match the `missing` field can be used. Both the `source` and all `has` items must match and all…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  redirects() {\n    return [\n      // if the header `x-redirect-me` is present,\n      // this redirect will be applied\n      {\n        source: '/:path((?!another-page$).*)',…", "filename": "next.config.js"}], "chunk_position": 70, "heading_path": "Header, Cookie, and Query Matching > Header, Cookie, and Query Matching", "breadcrumbs": "next.config.js: redirects | Next.js > Header, Cookie, and Query Matching > Header, Cookie, and Query Matching"}, {"id": "7fcd56d88faa8174", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects", "page_title": "next.config.js: redirects | Next.js", "page_type": "reference", "page_summary": "Documentation for the `redirects` key in `next.config.js`, which allows redirecting incoming request paths to different destination paths, including path matching, header/cookie/query matching,…", "heading": "Redirects with basePath support", "content": "Page: next.config.js: redirects | Next.js\nSection: Redirects with basePath support\n\nWhen leveraging [`basePath` support](/docs/app/api-reference/config/next-config-js/basePath) with redirects each `source` and `destination` is automatically prefixed with the `basePath` unless you…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  basePath: '/docs',\n \n  redirects() {\n    return [\n      {\n        source: '/with-basePath', // automatically becomes /docs/with-basePath\n        destination: '/another', //…", "filename": "next.config.js"}], "chunk_position": 70, "heading_path": "Redirects with basePath support > Redirects with basePath support", "breadcrumbs": "next.config.js: redirects | Next.js > Redirects with basePath support > Redirects with basePath support"}, {"id": "dffdab167a516fb0", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects", "page_title": "next.config.js: redirects | Next.js", "page_type": "reference", "page_summary": "Documentation for the `redirects` key in `next.config.js`, which allows redirecting incoming request paths to different destination paths, including path matching, header/cookie/query matching,…", "heading": "Redirects with i18n support", "content": "Page: next.config.js: redirects | Next.js\nSection: Redirects with i18n support\n\nWhen implementing redirects with internationalization in the App Router, you can include locales in `next.config.js` redirects, but only as hardcoded paths.\n\nFor dynamic or per-request locale…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  redirects() {\n    return [\n      {\n        // Manually handle locale prefixes for App Router\n        source: '/en/old-path',\n        destination: '/en/new-path',…", "filename": "next.config.js"}], "chunk_position": 70, "heading_path": "Redirects with i18n support > Redirects with i18n support", "breadcrumbs": "next.config.js: redirects | Next.js > Redirects with i18n support > Redirects with i18n support"}, {"id": "db129fd60ded0afd", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects", "page_title": "next.config.js: redirects | Next.js", "page_type": "reference", "page_summary": "Documentation for the `redirects` key in `next.config.js`, which allows redirecting incoming request paths to different destination paths, including path matching, header/cookie/query matching,…", "heading": "Other Redirects", "content": "Page: next.config.js: redirects | Next.js\nSection: Other Redirects\n\n- Inside [API Routes](/docs/pages/building-your-application/routing/api-routes) and [Route Handlers](/docs/app/api-reference/file-conventions/route), you can redirect based on the incoming request.\n-…", "code_blocks": [], "chunk_position": 70, "heading_path": "Other Redirects > Other Redirects", "breadcrumbs": "next.config.js: redirects | Next.js > Other Redirects > Other Redirects"}, {"id": "bc21aad2aa45450b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects", "page_title": "next.config.js: redirects | Next.js", "page_type": "reference", "page_summary": "Documentation for the `redirects` key in `next.config.js`, which allows redirecting incoming request paths to different destination paths, including path matching, header/cookie/query matching,…", "heading": "Version History", "content": "Page: next.config.js: redirects | Next.js\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v13.3.0` | `missing` added. |\n| `v10.2.0` | `has` added. |\n| `v9.5.0` | `redirects` added. |", "code_blocks": [], "chunk_position": 70, "heading_path": "Version History > Version History", "breadcrumbs": "next.config.js: redirects | Next.js > Version History > Version History"}, {"id": "edaa020eecaea1cb", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "rewrites", "content": "Page: next.config.js: rewrites | Next.js\nSection: rewrites\n\nRewrites allow you to map an incoming request path to a different destination path. Rewrites act as a URL proxy and mask the destination path, making it appear the user hasn't changed their location…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  rewrites() {\n    return [\n      {\n        source: '/about',\n        destination: '/',\n      },\n    ]\n  },\n}", "filename": "next.config.js"}], "chunk_position": 71, "heading_path": "rewrites > rewrites", "breadcrumbs": "next.config.js: rewrites | Next.js > rewrites > rewrites"}, {"id": "7271554f0870adf3", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "Rewrite properties", "content": "Page: next.config.js: rewrites | Next.js\nSection: Rewrite properties\n\nThe following properties are available on each rewrite object:", "code_blocks": [], "chunk_position": 71, "heading_path": "Rewrite properties > Rewrite properties", "breadcrumbs": "next.config.js: rewrites | Next.js > Rewrite properties > Rewrite properties"}, {"id": "a05b16e4e9a34872", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "Rewrites array vs object", "content": "Page: next.config.js: rewrites | Next.js\nSection: Rewrites array vs object\n\nWhen the `rewrites` function returns an array, rewrites are applied after checking the filesystem (pages and `/public` files) and before dynamic routes. When the `rewrites` function returns an object…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  rewrites() {\n    return {\n      beforeFiles: [\n        // These rewrites are checked after headers/redirects\n        // and before all files including _next/public files which…", "filename": "next.config.js"}], "chunk_position": 71, "heading_path": "Rewrites array vs object > Rewrites array vs object", "breadcrumbs": "next.config.js: rewrites | Next.js > Rewrites array vs object > Rewrites array vs object"}, {"id": "01f83629b4a67ca3", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "Order of checks", "content": "Page: next.config.js: rewrites | Next.js\nSection: Order of checks\n\nThe order Next.js routes are checked is: headers are checked/applied, redirects are checked/applied, proxy, `beforeFiles` rewrites: for each entry, if `source`, `has`, and `missing` matches the…", "code_blocks": [], "chunk_position": 71, "heading_path": "Order of checks > Order of checks", "breadcrumbs": "next.config.js: rewrites | Next.js > Order of checks > Order of checks"}, {"id": "48dc749632c2104f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "Rewrite parameters", "content": "Page: next.config.js: rewrites | Next.js\nSection: Rewrite parameters\n\nWhen using parameters in a rewrite the parameters will be passed in the query by default when none of the parameters are used in the `destination`. If a parameter is used in the destination none of…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  rewrites() {\n    return [\n      {\n        source: '/old-about/:path*',\n        destination: '/about', // The :path parameter isn't used here so will be automatically passed in…", "filename": "next.config.js"}, {"language": "javascript", "code": "module.exports = {\n  rewrites() {\n    return [\n      {\n        source: '/docs/:path*',\n        destination: '/:path*', // The :path parameter is used here so will not be automatically passed in the…", "filename": "next.config.js"}, {"language": "javascript", "code": "module.exports = {\n  rewrites() {\n    return [\n      {\n        source: '/:first/:second',\n        destination: '/:first?second=:second',\n        // Since the :first parameter is used in the…", "filename": "next.config.js"}], "chunk_position": 71, "heading_path": "Rewrite parameters > Rewrite parameters", "breadcrumbs": "next.config.js: rewrites | Next.js > Rewrite parameters > Rewrite parameters"}, {"id": "decea0c4e74416a0", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "Path Matching", "content": "Page: next.config.js: rewrites | Next.js\nSection: Path Matching\n\nPath matches are allowed, for example `/blog/:slug` will match `/blog/first-post` (no nested paths). The pattern `/blog/:slug` matches `/blog/first-post` and `/blog/post-1` but not `/blog/a/b` (no…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  rewrites() {\n    return [\n      {\n        source: '/blog/:slug',\n        destination: '/news/:slug', // Matched parameters can be used in the destination\n      },\n    ]\n  },\n}", "filename": "next.config.js"}], "chunk_position": 71, "heading_path": "Path Matching > Path Matching", "breadcrumbs": "next.config.js: rewrites | Next.js > Path Matching > Path Matching"}, {"id": "6f6f6aa0a8014f85", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "Wildcard Path Matching", "content": "Page: next.config.js: rewrites | Next.js\nSection: Wildcard Path Matching\n\nTo match a wildcard path you can use `*` after a parameter, for example `/blog/:slug*` will match `/blog/a/b/c/d/hello-world`.", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  rewrites() {\n    return [\n      {\n        source: '/blog/:slug*',\n        destination: '/news/:slug*', // Matched parameters can be used in the destination\n      },\n    ]\n  },\n}", "filename": "next.config.js"}], "chunk_position": 71, "heading_path": "Wildcard Path Matching > Wildcard Path Matching", "breadcrumbs": "next.config.js: rewrites | Next.js > Wildcard Path Matching > Wildcard Path Matching"}, {"id": "767ddf581f9b0c05", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "Regex Path Matching", "content": "Page: next.config.js: rewrites | Next.js\nSection: Regex Path Matching\n\nTo match a regex path you can wrap the regex in parenthesis after a parameter, for example `/blog/:slug(\\d{1,})` will match `/blog/123` but not `/blog/abc`. The following characters `(`, `)`, `{`,…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  rewrites() {\n    return [\n      {\n        source: '/old-blog/:post(\\d{1,})',\n        destination: '/blog/:post', // Matched parameters can be used in the destination\n      },…", "filename": "next.config.js"}, {"language": "javascript", "code": "module.exports = {\n  rewrites() {\n    return [\n      {\n        // this will match `/english(default)/something` being requested\n        source: '/english\\(default\\)/:slug',\n        destination:…", "filename": "next.config.js"}], "chunk_position": 71, "heading_path": "Regex Path Matching > Regex Path Matching", "breadcrumbs": "next.config.js: rewrites | Next.js > Regex Path Matching > Regex Path Matching"}, {"id": "94cf8958afe695e1", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "Header, Cookie, and Query Matching", "content": "Page: next.config.js: rewrites | Next.js\nSection: Header, Cookie, and Query Matching\n\nTo only match a rewrite when header, cookie, or query values also match the `has` field or don't match the `missing` field can be used. Both the `source` and all `has` items must match and all…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  rewrites() {\n    return [\n      // if the header `x-rewrite-me` is present,\n      // this rewrite will be applied\n      {\n        source: '/:path*',\n        has: [\n          {…", "filename": "next.config.js"}], "chunk_position": 71, "heading_path": "Header, Cookie, and Query Matching > Header, Cookie, and Query Matching", "breadcrumbs": "next.config.js: rewrites | Next.js > Header, Cookie, and Query Matching > Header, Cookie, and Query Matching"}, {"id": "ef7f468fb214b117", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "Rewriting to an external URL", "content": "Page: next.config.js: rewrites | Next.js\nSection: Rewriting to an external URL\n\nRewrites allow you to rewrite to an external URL. This is especially useful for incrementally adopting Next.js. The following is an example rewrite for redirecting the `/blog` route of your main app…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  rewrites() {\n    return [\n      {\n        source: '/blog',\n        destination: 'https://example.com/blog',\n      },\n      {\n        source: '/blog/:slug',\n        destination:…", "filename": "next.config.js"}, {"language": "javascript", "code": "module.exports = {\n  trailingSlash: true,\n  rewrites() {\n    return [\n      {\n        source: '/blog/',\n        destination: 'https://example.com/blog/',\n      },\n      {\n        source:…", "filename": "next.config.js"}], "chunk_position": 71, "heading_path": "Rewriting to an external URL > Rewriting to an external URL", "breadcrumbs": "next.config.js: rewrites | Next.js > Rewriting to an external URL > Rewriting to an external URL"}, {"id": "afe9b968989a8279", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "Incremental adoption of Next.js", "content": "Page: next.config.js: rewrites | Next.js\nSection: Incremental adoption of Next.js\n\nYou can also have Next.js fall back to proxying to an existing website after checking all Next.js routes. This way you don't have to change the rewrites configuration when migrating more pages to…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  rewrites() {\n    return {\n      fallback: [\n        {\n          source: '/:path*',\n          destination: `https://custom-routes-proxying-endpoint.vercel.app/:path*`,\n        },…", "filename": "next.config.js"}], "chunk_position": 71, "heading_path": "Incremental adoption of Next.js > Incremental adoption of Next.js", "breadcrumbs": "next.config.js: rewrites | Next.js > Incremental adoption of Next.js > Incremental adoption of Next.js"}, {"id": "ae45b82161b0ea10", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "Rewrites with basePath support", "content": "Page: next.config.js: rewrites | Next.js\nSection: Rewrites with basePath support\n\nWhen leveraging `basePath` support with rewrites each `source` and `destination` is automatically prefixed with the `basePath` unless you add `basePath: false` to the rewrite.", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  basePath: '/docs',\n \n  rewrites() {\n    return [\n      {\n        source: '/with-basePath', // automatically becomes /docs/with-basePath\n        destination: '/another', //…", "filename": "next.config.js"}], "chunk_position": 71, "heading_path": "Rewrites with basePath support > Rewrites with basePath support", "breadcrumbs": "next.config.js: rewrites | Next.js > Rewrites with basePath support > Rewrites with basePath support"}, {"id": "0b2dd15d85ecacbe", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites", "page_title": "next.config.js: rewrites | Next.js", "page_type": "reference", "page_summary": "Documentation for the rewrites configuration option in next.config.js, which allows mapping incoming request paths to different destination paths, acting as a URL proxy.", "heading": "Version History", "content": "Page: next.config.js: rewrites | Next.js\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v13.3.0` | `missing` added. |\n| `v10.2.0` | `has` added. |\n| `v9.5.0` | Headers added. |", "code_blocks": [], "chunk_position": 71, "heading_path": "Version History > Version History", "breadcrumbs": "next.config.js: rewrites | Next.js > Version History > Version History"}, {"id": "5d5ed13b55f7c035", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/sassOptions", "page_title": "next.config.js: sassOptions | Next.js", "page_type": "api", "page_summary": "Reference for the `sassOptions` configuration option in next.config.js, which allows you to configure the Sass compiler.", "heading": "sassOptions", "content": "Page: next.config.js: sassOptions | Next.js\nSection: sassOptions\n\n`sassOptions` allow you to configure the Sass compiler.\n\n> **Good to know:**\n> - `sassOptions` are not typed outside of `implementation` because Next.js does not maintain the other possible…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst sassOptions = {\n  additionalData: `\n    $var: red;\n  `,\n}\n \nconst nextConfig: NextConfig = {\n  sassOptions: {\n    ...sassOptions,\n    implementation:…", "filename": "next.config.ts"}], "chunk_position": 72, "heading_path": "sassOptions > sassOptions", "breadcrumbs": "next.config.js: sassOptions | Next.js > sassOptions > sassOptions"}, {"id": "c8833a8201f43eff", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/serverActions", "page_title": "serverActions", "page_type": "api", "page_summary": "Options for configuring Server Actions behavior in Next.js application, including allowed origins and body size limit.", "heading": "allowedOrigins", "content": "Page: serverActions\nSection: allowedOrigins\n\nA list of extra safe origin domains from which Server Actions can be invoked. Next.js compares the origin of a Server Action request with the host domain, ensuring they match to prevent CSRF attacks.…", "code_blocks": [{"language": "javascript", "code": "/** @type {import('next').NextConfig} */\n\nmodule.exports = {\n  experimental: {\n    serverActions: {\n      allowedOrigins: ['my-proxy.com', '*.my-proxy.com'],\n    },\n  },\n}", "filename": ""}], "chunk_position": 73, "heading_path": "allowedOrigins > allowedOrigins", "breadcrumbs": "serverActions > allowedOrigins > allowedOrigins"}, {"id": "34947a7ee3ebb71f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/serverActions", "page_title": "serverActions", "page_type": "api", "page_summary": "Options for configuring Server Actions behavior in Next.js application, including allowed origins and body size limit.", "heading": "bodySizeLimit", "content": "Page: serverActions\nSection: bodySizeLimit\n\nBy default, the maximum size of the request body sent to a Server Action is 1MB, to prevent the consumption of excessive server resources in parsing large amounts of data, as well as potential DDoS…", "code_blocks": [{"language": "javascript", "code": "/** @type {import('next').NextConfig} */\n\nmodule.exports = {\n  experimental: {\n    serverActions: {\n      bodySizeLimit: '2mb',\n    },\n  },\n}", "filename": ""}], "chunk_position": 73, "heading_path": "bodySizeLimit > bodySizeLimit", "breadcrumbs": "serverActions > bodySizeLimit > bodySizeLimit"}, {"id": "4ece1ab323bf2b44", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/serverActions", "page_title": "serverActions", "page_type": "api", "page_summary": "Options for configuring Server Actions behavior in Next.js application, including allowed origins and body size limit.", "heading": "Enabling Server Actions (v13)", "content": "Page: serverActions\nSection: Enabling Server Actions (v13)\n\nServer Actions became a stable feature in Next.js 14, and are enabled by default. However, if you are using an earlier version of Next.js, you can enable them by setting `experimental.serverActions`…", "code_blocks": [{"language": "javascript", "code": "/** @type {import('next').NextConfig} */\nconst config = {\n  experimental: {\n    serverActions: true,\n  },\n}\n\nmodule.exports = config", "filename": ""}], "chunk_position": 73, "heading_path": "Enabling Server Actions (v13) > Enabling Server Actions (v13)", "breadcrumbs": "serverActions > Enabling Server Actions (v13) > Enabling Server Actions (v13)"}, {"id": "465440914787a872", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/serverComponentsHmrCache", "page_title": "serverComponentsHmrCache", "page_type": "api", "page_summary": "The experimental `serverComponentsHmrCache` option allows you to cache `fetch` responses in Server Components across HMR refreshes in local development, improving performance and reducing API costs.", "heading": "serverComponentsHmrCache", "content": "Page: serverComponentsHmrCache\nSection: serverComponentsHmrCache\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on GitHub.\n\nThe experimental `serverComponentsHmrCache` option…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    serverComponentsHmrCache: false, // defaults to true\n  },\n}\n \nexport default nextConfig", "filename": ""}], "chunk_position": 74, "heading_path": "serverComponentsHmrCache > serverComponentsHmrCache", "breadcrumbs": "serverComponentsHmrCache > serverComponentsHmrCache > serverComponentsHmrCache"}, {"id": "121a40cfefca0a4d", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/serverExternalPackages", "page_title": "serverExternalPackages", "page_type": "reference", "page_summary": "Describes the `serverExternalPackages` configuration option in Next.js, which allows opting out specific dependencies from Server Components bundling to use native Node.js require.", "heading": "serverExternalPackages", "content": "Page: serverExternalPackages\nSection: serverExternalPackages\n\nDependencies used inside [Server Components](/docs/app/getting-started/server-and-client-components) and [Route Handlers](/docs/app/api-reference/file-conventions/route) will automatically be bundled…", "code_blocks": [{"language": "javascript", "code": "/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  serverExternalPackages: ['@acme/ui'],\n}\n \nmodule.exports = nextConfig", "filename": ""}], "chunk_position": 75, "heading_path": "serverExternalPackages > serverExternalPackages", "breadcrumbs": "serverExternalPackages > serverExternalPackages > serverExternalPackages"}, {"id": "07e77651362ad9ee", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/staleTimes", "page_title": "staleTimes", "page_type": "api", "page_summary": "This page documents the experimental `staleTimes` configuration option in `next.config.js`, which controls client cache revalidation times for dynamic and static page segments.", "heading": "staleTimes", "content": "Page: staleTimes\nSection: staleTimes\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on…", "code_blocks": [{"language": "js", "code": "/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  experimental: {\n    staleTimes: {\n      dynamic: 30,\n      static: 180,\n    },\n  },\n}\n \nmodule.exports = nextConfig", "filename": "next.config.js"}], "chunk_position": 76, "heading_path": "staleTimes > staleTimes", "breadcrumbs": "staleTimes > staleTimes > staleTimes"}, {"id": "d55b1a58536c1891", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/staleTimes", "page_title": "staleTimes", "page_type": "api", "page_summary": "This page documents the experimental `staleTimes` configuration option in `next.config.js`, which controls client cache revalidation times for dynamic and static page segments.", "heading": "Version History", "content": "Page: staleTimes\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v15.0.0` | The `dynamic` `staleTimes` default changed from 30s to 0s. |\n| `v14.2.0` | Experimental `staleTimes` introduced. |", "code_blocks": [], "chunk_position": 76, "heading_path": "Version History > Version History", "breadcrumbs": "staleTimes > Version History > Version History"}, {"id": "7deab79d8c779cf8", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/staticGeneration", "page_title": "next.config.js: staticGeneration*", "page_type": "api", "page_summary": "Explains the experimental `staticGeneration*` options in `next.config.js` that configure the Static Generation process, including retry count, maximum concurrency per worker, and minimum pages per…", "heading": "staticGeneration*", "content": "Page: next.config.js: staticGeneration*\nSection: staticGeneration*\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on GitHub. The `staticGeneration*` options allow you to configure…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    staticGenerationRetryCount: 1,\n    staticGenerationMaxConcurrency: 8,…", "filename": "next.config.ts"}], "chunk_position": 77, "heading_path": "staticGeneration* > staticGeneration*", "breadcrumbs": "next.config.js: staticGeneration* > staticGeneration* > staticGeneration*"}, {"id": "a24f10a8b52eed2f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/staticGeneration", "page_title": "next.config.js: staticGeneration*", "page_type": "api", "page_summary": "Explains the experimental `staticGeneration*` options in `next.config.js` that configure the Static Generation process, including retry count, maximum concurrency per worker, and minimum pages per…", "heading": "Config Options", "content": "Page: next.config.js: staticGeneration*\nSection: Config Options\n\nThe following options are available:\n\n- `staticGenerationRetryCount`: The number of times to retry a failed page generation before failing the build.\n- `staticGenerationMaxConcurrency`: The maximum…", "code_blocks": [], "chunk_position": 77, "heading_path": "Config Options > Config Options", "breadcrumbs": "next.config.js: staticGeneration* > Config Options > Config Options"}, {"id": "12593c0992f2f664", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/supportsImmutableAssets", "page_title": "next.config.js: supportsImmutableAssets | Next.js", "page_type": "api", "page_summary": "This page describes the `supportsImmutableAssets` configuration option in next.config.js, used primarily by adapter authors to opt out of immutable static assets when an adapter has enabled support…", "heading": "supportsImmutableAssets", "content": "Page: next.config.js: supportsImmutableAssets | Next.js\nSection: supportsImmutableAssets\n\n**Attention**: This option is primarily intended for [adapter](/docs/app/api-reference/adapters) authors. App developers should only set it when troubleshooting adapter-specific issues.\n\n**Enabling…", "code_blocks": [{"language": "javascript", "code": "/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  supportsImmutableAssets: false,\n}\n \nmodule.exports = nextConfig", "filename": "next.config.js"}], "chunk_position": 78, "heading_path": "supportsImmutableAssets > supportsImmutableAssets", "breadcrumbs": "next.config.js: supportsImmutableAssets | Next.js > supportsImmutableAssets > supportsImmutableAssets"}, {"id": "4b9ebc2c563acf33", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/supportsImmutableAssets", "page_title": "next.config.js: supportsImmutableAssets | Next.js", "page_type": "api", "page_summary": "This page describes the `supportsImmutableAssets` configuration option in next.config.js, used primarily by adapter authors to opt out of immutable static assets when an adapter has enabled support…", "heading": "Version History", "content": "Page: next.config.js: supportsImmutableAssets | Next.js\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v16.3.0` | Added support for immutable static assets. |", "code_blocks": [], "chunk_position": 78, "heading_path": "Version History > Version History", "breadcrumbs": "next.config.js: supportsImmutableAssets | Next.js > Version History > Version History"}, {"id": "f8d8e59ba81a9e78", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/taint", "page_title": "next.config.js: taint | Next.js", "page_type": "reference", "page_summary": "Explains the experimental `taint` configuration option in Next.js, which enables React APIs for tainting objects and values to prevent sensitive data from being sent to the client. Includes usage,…", "heading": "Usage", "content": "Page: next.config.js: taint | Next.js\nSection: Usage\n\nThe `taint` option enables support for experimental React APIs for tainting objects and values. This feature helps prevent sensitive data from being accidentally passed to the client. When enabled,…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    taint: true,\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 79, "heading_path": "Usage > Usage", "breadcrumbs": "next.config.js: taint | Next.js > Usage > Usage"}, {"id": "3ef625ad7ce55806", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/taint", "page_title": "next.config.js: taint | Next.js", "page_type": "reference", "page_summary": "Explains the experimental `taint` configuration option in Next.js, which enables React APIs for tainting objects and values to prevent sensitive data from being sent to the client. Includes usage,…", "heading": "Caveats", "content": "Page: next.config.js: taint | Next.js\nSection: Caveats\n\nTainting can only keep track of objects by reference. Copying an object creates an untainted version, which loses all guarantees given by the API. You'll need to taint the copy.\n\nTainting cannot keep…", "code_blocks": [], "chunk_position": 79, "heading_path": "Caveats > Caveats", "breadcrumbs": "next.config.js: taint | Next.js > Caveats > Caveats"}, {"id": "bd92a461a0360fcb", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/taint", "page_title": "next.config.js: taint | Next.js", "page_type": "reference", "page_summary": "Explains the experimental `taint` configuration option in Next.js, which enables React APIs for tainting objects and values to prevent sensitive data from being sent to the client. Includes usage,…", "heading": "Tainting an object reference", "content": "Page: next.config.js: taint | Next.js\nSection: Tainting an object reference\n\nIn this case, the `getUserDetails` function returns data about a given user. We taint the user object reference, so that it cannot cross a Server-Client boundary. For example, assuming `UserCard` is…", "code_blocks": [{"language": "typescript", "code": "import { experimental_taintObjectReference } from 'react'\n \nfunction getUserDetails(id: string): UserDetails {\n  const user = await db.queryUserById(id)\n \n  experimental_taintObjectReference(\n    'Do…", "filename": ""}, {"language": "typescript", "code": "export async function ContactPage({\n  params,\n}: {\n  params: Promise<{ id: string }>\n}) {\n  const { id } = await params\n  const userDetails = await getUserDetails(id)\n \n  return (\n    <UserCard…", "filename": ""}, {"language": "typescript", "code": "export async function ContactPage({\n  params,\n}: {\n  params: Promise<{ id: string }>\n}) {\n  const userDetails = await getUserDetails(id)\n \n  // Throws an error\n  return <UserCard user={userDetails}…", "filename": ""}], "chunk_position": 79, "heading_path": "Tainting an object reference > Tainting an object reference", "breadcrumbs": "next.config.js: taint | Next.js > Tainting an object reference > Tainting an object reference"}, {"id": "82dcbe42e63ea205", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/taint", "page_title": "next.config.js: taint | Next.js", "page_type": "reference", "page_summary": "Explains the experimental `taint` configuration option in Next.js, which enables React APIs for tainting objects and values to prevent sensitive data from being sent to the client. Includes usage,…", "heading": "Tainting a unique value", "content": "Page: next.config.js: taint | Next.js\nSection: Tainting a unique value\n\nIn this case, we can access the server configuration by awaiting calls to `config.getConfigDetails`. However, the system configuration contains the `SERVICE_API_KEY` that we don't want to expose to…", "code_blocks": [{"language": "typescript", "code": "import { experimental_taintUniqueValue } from 'react'\n \nfunction getSystemConfig(): SystemConfig {\n  const config = await config.getConfigDetails()\n \n  experimental_taintUniqueValue(\n    'Do not pass…", "filename": ""}, {"language": "typescript", "code": "export async function Dashboard() {\n  const systemConfig = await getSystemConfig()\n \n  return <ClientDashboard version={systemConfig.SERVICE_API_VERSION} />\n}", "filename": ""}, {"language": "typescript", "code": "export async function Dashboard() {\n  const systemConfig = await getSystemConfig()\n  // Someone makes a mistake in a PR\n  const version = systemConfig.SERVICE_API_KEY\n \n  return <ClientDashboard…", "filename": ""}, {"language": "typescript", "code": "export async function Dashboard() {\n  const systemConfig = await getSystemConfig()\n  // Someone makes a mistake in a PR\n  const version = `version::${systemConfig.SERVICE_API_KEY}`\n \n  return…", "filename": ""}], "chunk_position": 79, "heading_path": "Tainting a unique value > Tainting a unique value", "breadcrumbs": "next.config.js: taint | Next.js > Tainting a unique value > Tainting a unique value"}, {"id": "0310a1f7164d73ba", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/trailingSlash", "page_title": "trailingSlash", "page_type": "reference", "page_summary": "Describes the `trailingSlash` configuration option in Next.js, which controls whether URLs with trailing slashes are redirected to non-trailing-slash versions or vice versa, with exceptions for…", "heading": "trailingSlash", "content": "Page: trailingSlash\nSection: trailingSlash\n\nBy default Next.js will redirect URLs with trailing slashes to their counterpart without a trailing slash. For example `/about/` will redirect to `/about`. You can configure this behavior to act the…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  trailingSlash: true,\n}", "filename": "next.config.js"}], "chunk_position": 80, "heading_path": "trailingSlash > trailingSlash", "breadcrumbs": "trailingSlash > trailingSlash > trailingSlash"}, {"id": "095d7e0033dd70a4", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/trailingSlash", "page_title": "trailingSlash", "page_type": "reference", "page_summary": "Describes the `trailingSlash` configuration option in Next.js, which controls whether URLs with trailing slashes are redirected to non-trailing-slash versions or vice versa, with exceptions for…", "heading": "Version History", "content": "Page: trailingSlash\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v9.5.0` | `trailingSlash` added. |", "code_blocks": [], "chunk_position": 80, "heading_path": "Version History > Version History", "breadcrumbs": "trailingSlash > Version History > Version History"}, {"id": "de01315b2fe715f0", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/transpilePackages", "page_title": "transpilePackages", "page_type": "api", "page_summary": "Use transpilePackages to compile and bundle a dependency instead of treating it as untouched runtime code. This page explains when the option is needed and provides configuration examples.", "heading": "Overview", "content": "Page: transpilePackages\nSection: Overview\n\nUse `transpilePackages` to compile and bundle a dependency instead of treating it as untouched runtime code. Values are package names, including scoped names like `@scope/pkg`. Paths and glob…", "code_blocks": [{"language": "js", "code": "/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  transpilePackages: ['package-name', '@scope/pkg'],\n}\n \nmodule.exports = nextConfig", "filename": "next.config.js"}], "chunk_position": 81, "heading_path": "Overview > Overview", "breadcrumbs": "transpilePackages > Overview > Overview"}, {"id": "15053749c63e0e25", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/transpilePackages", "page_title": "transpilePackages", "page_type": "api", "page_summary": "Use transpilePackages to compile and bundle a dependency instead of treating it as untouched runtime code. This page explains when the option is needed and provides configuration examples.", "heading": "When you need it", "content": "Page: transpilePackages\nSection: When you need it\n\nTurbopack transpiles workspace packages (npm, pnpm, or Yarn workspaces) in your monorepo automatically under both routers. Webpack does the same for the App Router. Add a package to…", "code_blocks": [], "chunk_position": 81, "heading_path": "When you need it > When you need it", "breadcrumbs": "transpilePackages > When you need it > When you need it"}, {"id": "0af200890703f365", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/transpilePackages", "page_title": "transpilePackages", "page_type": "api", "page_summary": "Use transpilePackages to compile and bundle a dependency instead of treating it as untouched runtime code. This page explains when the option is needed and provides configuration examples.", "heading": "Version History", "content": "Page: transpilePackages\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v13.0.0` | `transpilePackages` added. |", "code_blocks": [], "chunk_position": 81, "heading_path": "Version History > Version History", "breadcrumbs": "transpilePackages > Version History > Version History"}, {"id": "c5c5d17ed2cd0d81", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Overview", "content": "Page: turbopack\nSection: Overview\n\nThe `turbopack` option lets you customize [Turbopack](/docs/app/api-reference/turbopack) to transform different files and change how modules are resolved.\n\n> **Good to know** : The `turbopack` option…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  turbopack: {\n    // ...\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 82, "heading_path": "Overview > Overview", "breadcrumbs": "turbopack > Overview > Overview"}, {"id": "5d12285344de46d2", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Options", "content": "Page: turbopack\nSection: Options\n\nThe following options are available for the `turbopack` configuration:\n\n| Option | Description |\n| --- | --- |\n| `root` | Sets the application root directory. Should be an absolute path. |\n| `rules`…", "code_blocks": [], "chunk_position": 82, "heading_path": "Options > Options", "breadcrumbs": "turbopack > Options > Options"}, {"id": "51e8a31fb8f71b22", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Supported loaders", "content": "Page: turbopack\nSection: Supported loaders\n\nThe following loaders have been tested to work with Turbopack's webpack loader implementation, but many other webpack loaders should work as well even if not listed here:\n\n-…", "code_blocks": [], "chunk_position": 82, "heading_path": "Supported loaders > Supported loaders", "breadcrumbs": "turbopack > Supported loaders > Supported loaders"}, {"id": "6e29956a851207c0", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Missing Webpack loader features", "content": "Page: turbopack\nSection: Missing Webpack loader features\n\nTurbopack uses the [`loader-runner`](https://github.com/webpack/loader-runner) library to execute webpack loaders, which provides most of the standard loader API. However, some features are not…", "code_blocks": [], "chunk_position": 82, "heading_path": "Missing Webpack loader features > Missing Webpack loader features", "breadcrumbs": "turbopack > Missing Webpack loader features > Missing Webpack loader features"}, {"id": "a5c340464efdbb8e", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Root directory", "content": "Page: turbopack\nSection: Root directory\n\nTurbopack uses the root directory to resolve modules. Files outside of the project root are not resolved.\n\nThe reason files are not resolved outside of the project root is to improve cache…", "code_blocks": [{"language": "javascript", "code": "const path = require('path')\nmodule.exports = {\n  turbopack: {\n    root: path.join(__dirname, '..'),\n  },\n}", "filename": "next.config.js"}], "chunk_position": 82, "heading_path": "Root directory > Root directory", "breadcrumbs": "turbopack > Root directory > Root directory"}, {"id": "a1096fd33fea4e16", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Configuring webpack loaders", "content": "Page: turbopack\nSection: Configuring webpack loaders\n\nIf you need loader support beyond what's built in, many webpack loaders already work with Turbopack. There are currently some limitations:\n\n- Only a core subset of the webpack loader API is…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  turbopack: {\n    rules: {\n      '*.svg': {\n        loaders: ['@svgr/webpack'],\n        as: '*.js',\n      },\n    },\n  },\n}", "filename": "next.config.js"}, {"language": "javascript", "code": "module.exports = {\n  turbopack: {\n    rules: {\n      '*.svg': {\n        loaders: [\n          {\n            loader: '@svgr/webpack',\n            options: {\n              icon: true,\n            },…", "filename": "next.config.js"}], "chunk_position": 82, "heading_path": "Configuring webpack loaders > Configuring webpack loaders", "breadcrumbs": "turbopack > Configuring webpack loaders > Configuring webpack loaders"}, {"id": "1d33870212d2cb18", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Advanced webpack loader conditions", "content": "Page: turbopack\nSection: Advanced webpack loader conditions\n\nYou can further restrict where a loader runs using the advanced `condition` syntax:\n\n- Supported boolean operators are `{all: [...]}`, `{any: [...]}` and `{not: ...}`.\n- Supported customizable…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  turbopack: {\n    rules: {\n      // '*' will match all file paths, but we restrict where our\n      // rule runs with a condition.\n      '*': {\n        condition: {\n          all:…", "filename": "next.config.js"}, {"language": "javascript", "code": "module.exports = {\n  turbopack: {\n    rules: {\n      '*.svg': [\n        {\n          condition: 'browser',\n          loaders: ['@svgr/webpack'],\n          as: '*.js',\n        },\n        {…", "filename": "next.config.js"}], "chunk_position": 82, "heading_path": "Advanced webpack loader conditions > Advanced webpack loader conditions", "breadcrumbs": "turbopack > Advanced webpack loader conditions > Advanced webpack loader conditions"}, {"id": "e2123d677ccb1024", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Module types", "content": "Page: turbopack\nSection: Module types\n\nYou can set the module type directly without using a loader. This is useful for changing how files are processed, similar to webpack's [`type`](https://webpack.js.org/configuration/module/#ruletype)…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  turbopack: {\n    rules: {\n      '*.svg': {\n        type: 'asset',\n      },\n    },\n  },\n}", "filename": "next.config.js"}, {"language": "typescript", "code": "import svgUrl from './icon.svg'\n \nexport default function Page() {\n  return <img src={svgUrl} alt=\"Icon\" />\n}", "filename": "app/page.tsx"}], "chunk_position": 82, "heading_path": "Module types > Module types", "breadcrumbs": "turbopack > Module types > Module types"}, {"id": "b1420e014e42cfc9", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Inline loader configuration with import attributes", "content": "Page: turbopack\nSection: Inline loader configuration with import attributes\n\nYou can apply a Turbopack loader to an individual import using the `with` clause (import attributes). This is specified per-import rather than globally via `turbopack.rules`.\n\nThis is useful when you…", "code_blocks": [{"language": "typescript", "code": "// Apply a raw loader to import a .txt file as a JavaScript module\nimport rawText from '../data.txt' with { turbopackLoader: 'raw-loader', turbopackAs: '*.js' }\n \nexport default function Page() {…", "filename": "app/page.tsx"}, {"language": "typescript", "code": "import value from '../data.js' with { turbopackLoader: 'string-replace-loader', turbopackLoaderOptions: '{\"search\":\"PLACEHOLDER\",\"replace\":\"replaced value\"}' }", "filename": "app/page.tsx"}], "chunk_position": 82, "heading_path": "Inline loader configuration with import attributes > Inline loader configuration with import attributes", "breadcrumbs": "turbopack > Inline loader configuration with import attributes > Inline loader configuration with import attributes"}, {"id": "01b13a8eca83555b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Resolving aliases", "content": "Page: turbopack\nSection: Resolving aliases\n\nTurbopack can be configured to modify module resolution through aliases, similar to webpack's [`resolve.alias`](https://webpack.js.org/configuration/resolve/#resolvealias) configuration.\n\nTo…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  turbopack: {\n    resolveAlias: {\n      underscore: 'lodash',\n      mocha: { browser: 'mocha/browser-entry.js' },\n    },\n  },\n}", "filename": "next.config.js"}], "chunk_position": 82, "heading_path": "Resolving aliases > Resolving aliases", "breadcrumbs": "turbopack > Resolving aliases > Resolving aliases"}, {"id": "461c93167f01f12f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Resolving custom extensions", "content": "Page: turbopack\nSection: Resolving custom extensions\n\nTurbopack can be configured to resolve modules with custom extensions, similar to webpack's [`resolve.extensions`](https://webpack.js.org/configuration/resolve/#resolveextensions) configuration.\n\nTo…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  turbopack: {\n    resolveExtensions: ['.mdx', '.tsx', '.ts', '.jsx', '.js', '.mjs', '.json'],\n  },\n}", "filename": "next.config.js"}], "chunk_position": 82, "heading_path": "Resolving custom extensions > Resolving custom extensions", "breadcrumbs": "turbopack > Resolving custom extensions > Resolving custom extensions"}, {"id": "f6d015c6959cd24c", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Debug IDs", "content": "Page: turbopack\nSection: Debug IDs\n\nTurbopack can be configured to generate [debug IDs](https://github.com/tc39/ecma426/blob/main/proposals/debug-id.md) in JavaScript bundles and source maps.\n\nTo configure debug IDs, use the `debugIds`…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  turbopack: {\n    debugIds: true,\n  },\n}", "filename": "next.config.js"}], "chunk_position": 82, "heading_path": "Debug IDs > Debug IDs", "breadcrumbs": "turbopack > Debug IDs > Debug IDs"}, {"id": "a2629d1d61c834df", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack", "page_title": "turbopack", "page_type": "api", "page_summary": "The `turbopack` option lets you customize Turbopack to transform different files and change how modules are resolved.", "heading": "Version History", "content": "Page: turbopack\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `16.2.0` | `turbopackLoader` import attributes were added. |\n| `16.2.0` | `turbopack.rules.*.type` was added. |\n| `16.2.0` |…", "code_blocks": [], "chunk_position": 82, "heading_path": "Version History > Version History", "breadcrumbs": "turbopack > Version History > Version History"}, {"id": "48fa7d8cdf2ecda9", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackChunking", "page_title": "turbopackChunking", "page_type": "api", "page_summary": "Configuration options for Turbopack's production JavaScript chunker in next.config.js, including size thresholds, component chunks, and heuristics for merging chunks.", "heading": "Overview", "content": "Page: turbopackChunking\nSection: Overview\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig = {\n  experimental: {\n    turbopackChunking: {\n      minChunkSize: 50000,\n      maxChunkCountPerGroup: 40,\n      maxMergeChunkSize: 200000,…", "filename": "next.config.ts"}], "chunk_position": 83, "heading_path": "Overview > Overview", "breadcrumbs": "turbopackChunking > Overview > Overview"}, {"id": "49e91b5438ab96e6", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackChunking", "page_title": "turbopackChunking", "page_type": "api", "page_summary": "Configuration options for Turbopack's production JavaScript chunker in next.config.js, including size thresholds, component chunks, and heuristics for merging chunks.", "heading": "Size Thresholds", "content": "Page: turbopackChunking\nSection: Size Thresholds\n\nThe following options control how aggressively Turbopack merges chunks and how large a chunk is allowed to grow. Sizes are in bytes of uncompressed, unminified code (roughly 5x the size of the…", "code_blocks": [], "chunk_position": 83, "heading_path": "Size Thresholds > Size Thresholds", "breadcrumbs": "turbopackChunking > Size Thresholds > Size Thresholds"}, {"id": "2633575e26166b5b", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackChunking", "page_title": "turbopackChunking", "page_type": "api", "page_summary": "Configuration options for Turbopack's production JavaScript chunker in next.config.js, including size thresholds, component chunks, and heuristics for merging chunks.", "heading": "Component Chunks", "content": "Page: turbopackChunking\nSection: Component Chunks\n\nProducing component chunks is an experimental feature that aims to give you the initial page load benefits of merged chunks without sacrificing reusability. This feature lets the runtime dynamically…", "code_blocks": [], "chunk_position": 83, "heading_path": "Component Chunks > Component Chunks", "breadcrumbs": "turbopackChunking > Component Chunks > Component Chunks"}, {"id": "23fc1bef57713a2d", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackChunking", "page_title": "turbopackChunking", "page_type": "api", "page_summary": "Configuration options for Turbopack's production JavaScript chunker in next.config.js, including size thresholds, component chunks, and heuristics for merging chunks.", "heading": "Heuristics", "content": "Page: turbopackChunking\nSection: Heuristics\n\nThese change the assumptions the chunker makes when weighing whether merging two chunks is worth it.\n\n- **`firstPageLoadPriority`** (a number between `0` and `1`): how heavily to weight the benefit…", "code_blocks": [], "chunk_position": 83, "heading_path": "Heuristics > Heuristics", "breadcrumbs": "turbopackChunking > Heuristics > Heuristics"}, {"id": "f9a4d133fd9b3772", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackFileSystemCache", "page_title": "Turbopack FileSystem Caching", "page_type": "api", "page_summary": "This page describes the Turbopack FileSystem Cache configuration options in Next.js, which enable caching of Turbopack's work across dev and build commands to speed up subsequent runs.", "heading": "Usage", "content": "Page: Turbopack FileSystem Caching\nSection: Usage\n\nTurbopack FileSystem Cache enables Turbopack to reduce work across `next dev` or `next build` commands. When enabled, Turbopack will save and restore data under the `.next` directory between runs,…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    turbopackFileSystemCacheForDev: true,\n    turbopackFileSystemCacheForBuild: true,\n  },\n}\n \nexport…", "filename": ""}], "chunk_position": 84, "heading_path": "Usage > Usage", "breadcrumbs": "Turbopack FileSystem Caching > Usage > Usage"}, {"id": "947f00c8eff01c81", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackFileSystemCache", "page_title": "Turbopack FileSystem Caching", "page_type": "api", "page_summary": "This page describes the Turbopack FileSystem Cache configuration options in Next.js, which enable caching of Turbopack's work across dev and build commands to speed up subsequent runs.", "heading": "Options", "content": "Page: Turbopack FileSystem Caching\nSection: Options\n\n- **`turbopackFileSystemCacheForDev`**  (default: `true`): caches Turbopack's work for `next dev` in `.next/dev/cache/turbopack`. Restarting the dev server reuses the previous compilation.\n\n-…", "code_blocks": [], "chunk_position": 84, "heading_path": "Options > Options", "breadcrumbs": "Turbopack FileSystem Caching > Options > Options"}, {"id": "090d253136a96ea7", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackFileSystemCache", "page_title": "Turbopack FileSystem Caching", "page_type": "api", "page_summary": "This page describes the Turbopack FileSystem Cache configuration options in Next.js, which enable caching of Turbopack's work across dev and build commands to speed up subsequent runs.", "heading": "Build environments", "content": "Page: Turbopack FileSystem Caching\nSection: Build environments\n\nThe build cache lives in `.next/cache`. Builds only get faster when that directory is restored before each build.\n\n- **Self-hosted builds** : reuse the same working directory between builds.…", "code_blocks": [], "chunk_position": 84, "heading_path": "Build environments > Build environments", "breadcrumbs": "Turbopack FileSystem Caching > Build environments > Build environments"}, {"id": "4d835a204f05ad87", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackFileSystemCache", "page_title": "Turbopack FileSystem Caching", "page_type": "api", "page_summary": "This page describes the Turbopack FileSystem Cache configuration options in Next.js, which enable caching of Turbopack's work across dev and build commands to speed up subsequent runs.", "heading": "Version History", "content": "Page: Turbopack FileSystem Caching\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v16.3.0` | FileSystem caching is enabled by default for builds |\n| `v16.1.0` | FileSystem caching is enabled by default for development |\n| `v16.0.0` | Beta…", "code_blocks": [], "chunk_position": 84, "heading_path": "Version History > Version History", "breadcrumbs": "Turbopack FileSystem Caching > Version History > Version History"}, {"id": "bdc8f5537c0d49dd", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackIgnoreIssue", "page_title": "turbopack.ignoreIssue", "page_type": "api", "page_summary": "The `turbopack.ignoreIssue` option allows you to filter out specific Turbopack errors and warnings so they do not appear in the CLI output or the error overlay. This is useful for suppressing known…", "heading": "turbopack.ignoreIssue", "content": "Page: turbopack.ignoreIssue\nSection: turbopack.ignoreIssue\n\nThe `turbopack.ignoreIssue` option allows you to filter out specific Turbopack errors and warnings so they do not appear in the CLI output or the error overlay. This is useful for suppressing known…", "code_blocks": [], "chunk_position": 85, "heading_path": "turbopack.ignoreIssue > turbopack.ignoreIssue", "breadcrumbs": "turbopack.ignoreIssue > turbopack.ignoreIssue > turbopack.ignoreIssue"}, {"id": "0b69e856afc92c42", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackIgnoreIssue", "page_title": "turbopack.ignoreIssue", "page_type": "api", "page_summary": "The `turbopack.ignoreIssue` option allows you to filter out specific Turbopack errors and warnings so they do not appear in the CLI output or the error overlay. This is useful for suppressing known…", "heading": "Usage", "content": "Page: turbopack.ignoreIssue\nSection: Usage\n\n```typescript\nimport type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  turbopack: {\n    ignoreIssue: [\n      {\n        path: '**/vendor/**',\n      },\n    ],\n  },\n}\n \nexport default nextConfig\n```", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  turbopack: {\n    ignoreIssue: [\n      {\n        path: '**/vendor/**',\n      },\n    ],\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 85, "heading_path": "Usage > Usage", "breadcrumbs": "turbopack.ignoreIssue > Usage > Usage"}, {"id": "14303d59f7b1eec2", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackIgnoreIssue", "page_title": "turbopack.ignoreIssue", "page_type": "api", "page_summary": "The `turbopack.ignoreIssue` option allows you to filter out specific Turbopack errors and warnings so they do not appear in the CLI output or the error overlay. This is useful for suppressing known…", "heading": "Options", "content": "Page: turbopack.ignoreIssue\nSection: Options\n\nEach rule in the `ignoreIssue` array is an object with the following fields:\n\n| Field | Type | Required | Description |\n| --- | --- | --- | --- |\n| `path` | `string \\| RegExp` | Yes | Matches against…", "code_blocks": [], "chunk_position": 85, "heading_path": "Options > Options", "breadcrumbs": "turbopack.ignoreIssue > Options > Options"}, {"id": "d33b1eb4a53fbcdb", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackIgnoreIssue", "page_title": "turbopack.ignoreIssue", "page_type": "api", "page_summary": "The `turbopack.ignoreIssue` option allows you to filter out specific Turbopack errors and warnings so they do not appear in the CLI output or the error overlay. This is useful for suppressing known…", "heading": "path", "content": "Page: turbopack.ignoreIssue\nSection: path\n\nA **glob pattern** (when a string) or **regular expression** that matches against the file path where the issue originated.", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  turbopack: {\n    ignoreIssue: [\n      // Glob pattern: suppress issues from any file under vendor/\n      { path: '**/vendor/**' },\n      // RegExp: suppress issues from files…", "filename": "next.config.js"}], "chunk_position": 85, "heading_path": "path > path", "breadcrumbs": "turbopack.ignoreIssue > path > path"}, {"id": "8e25698141846a54", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackIgnoreIssue", "page_title": "turbopack.ignoreIssue", "page_type": "api", "page_summary": "The `turbopack.ignoreIssue` option allows you to filter out specific Turbopack errors and warnings so they do not appear in the CLI output or the error overlay. This is useful for suppressing known…", "heading": "title", "content": "Page: turbopack.ignoreIssue\nSection: title\n\nAn **exact string match** (when a string) or **regular expression** that matches against the issue title.", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  turbopack: {\n    ignoreIssue: [\n      {\n        path: '**/src/**',\n        title: 'Module not found',\n      },\n    ],\n  },\n}", "filename": "next.config.js"}], "chunk_position": 85, "heading_path": "title > title", "breadcrumbs": "turbopack.ignoreIssue > title > title"}, {"id": "6ead02c9b5a1538c", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackIgnoreIssue", "page_title": "turbopack.ignoreIssue", "page_type": "api", "page_summary": "The `turbopack.ignoreIssue` option allows you to filter out specific Turbopack errors and warnings so they do not appear in the CLI output or the error overlay. This is useful for suppressing known…", "heading": "description", "content": "Page: turbopack.ignoreIssue\nSection: description\n\nAn **exact string match** (when a string) or **regular expression** that matches against the issue description.", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  turbopack: {\n    ignoreIssue: [\n      {\n        path: '**/src/**',\n        description: /Cannot find module 'optional-dep'/,\n      },\n    ],\n  },\n}", "filename": "next.config.js"}], "chunk_position": 85, "heading_path": "description > description", "breadcrumbs": "turbopack.ignoreIssue > description > description"}, {"id": "c11d3071b792692e", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackIgnoreIssue", "page_title": "turbopack.ignoreIssue", "page_type": "api", "page_summary": "The `turbopack.ignoreIssue` option allows you to filter out specific Turbopack errors and warnings so they do not appear in the CLI output or the error overlay. This is useful for suppressing known…", "heading": "Suppressing warnings for optional dependencies", "content": "Page: turbopack.ignoreIssue\nSection: Suppressing warnings for optional dependencies\n\nIf your code uses `try/catch` around an optional `require()` call, Turbopack may report a \"Module not found\" warning. You can suppress it:", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  turbopack: {\n    ignoreIssue: [\n      {\n        path: '**/lib/optional-feature/**',\n        title: 'Module not found',…", "filename": "next.config.ts"}], "chunk_position": 85, "heading_path": "Suppressing warnings for optional dependencies > Suppressing warnings for optional dependencies", "breadcrumbs": "turbopack.ignoreIssue > Suppressing warnings for optional dependencies > Suppressing warnings for optional dependencies"}, {"id": "7e29de24a48a2d81", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackIgnoreIssue", "page_title": "turbopack.ignoreIssue", "page_type": "api", "page_summary": "The `turbopack.ignoreIssue` option allows you to filter out specific Turbopack errors and warnings so they do not appear in the CLI output or the error overlay. This is useful for suppressing known…", "heading": "Combining multiple rules", "content": "Page: turbopack.ignoreIssue\nSection: Combining multiple rules\n\nYou can specify multiple rules to suppress different issues:", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  turbopack: {\n    ignoreIssue: [\n      { path: '**/vendor/**' },\n      { path: '**/legacy/**', title: 'Module not found' },\n      { path: /generated\\//, description: /expected…", "filename": "next.config.js"}], "chunk_position": 85, "heading_path": "Combining multiple rules > Combining multiple rules", "breadcrumbs": "turbopack.ignoreIssue > Combining multiple rules > Combining multiple rules"}, {"id": "9c386077beaf5658", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackIgnoreIssue", "page_title": "turbopack.ignoreIssue", "page_type": "api", "page_summary": "The `turbopack.ignoreIssue` option allows you to filter out specific Turbopack errors and warnings so they do not appear in the CLI output or the error overlay. This is useful for suppressing known…", "heading": "Version History", "content": "Page: turbopack.ignoreIssue\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v16.2.0` | `turbopack.ignoreIssue` introduced. |", "code_blocks": [], "chunk_position": 85, "heading_path": "Version History > Version History", "breadcrumbs": "turbopack.ignoreIssue > Version History > Version History"}, {"id": "f75a412199ec8114", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackIgnoreIssue", "page_title": "turbopack.ignoreIssue", "page_type": "api", "page_summary": "The `turbopack.ignoreIssue` option allows you to filter out specific Turbopack errors and warnings so they do not appear in the CLI output or the error overlay. This is useful for suppressing known…", "heading": "Next Steps", "content": "Page: turbopack.ignoreIssue\nSection: Next Steps\n\nLearn more about Turbopack configuration.\n\n- [turbopack: Configure Next.js with Turbopack-specific options](/docs/app/api-reference/config/next-config-js/turbopack)\n- [Turbopack: Turbopack is an…", "code_blocks": [], "chunk_position": 85, "heading_path": "Next Steps > Next Steps", "breadcrumbs": "turbopack.ignoreIssue > Next Steps > Next Steps"}, {"id": "8238ce41eeaa1322", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackLocalPostcssConfig", "page_title": "turbopackLocalPostcssConfig", "page_type": "reference", "page_summary": "This page documents the `turbopackLocalPostcssConfig` option in Next.js configuration, which changes how Turbopack resolves `postcss.config.js` files, allowing per-directory configs to take…", "heading": "Overview", "content": "Page: turbopackLocalPostcssConfig\nSection: Overview\n\nThe `turbopackLocalPostcssConfig` option changes how Turbopack resolves `postcss.config.js` files. When enabled, Turbopack searches for the config starting from the CSS file's own directory first,…", "code_blocks": [], "chunk_position": 86, "heading_path": "Overview > Overview", "breadcrumbs": "turbopackLocalPostcssConfig > Overview > Overview"}, {"id": "9a2cba76e5b756c2", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackLocalPostcssConfig", "page_title": "turbopackLocalPostcssConfig", "page_type": "reference", "page_summary": "This page documents the `turbopackLocalPostcssConfig` option in Next.js configuration, which changes how Turbopack resolves `postcss.config.js` files, allowing per-directory configs to take…", "heading": "Usage", "content": "Page: turbopackLocalPostcssConfig\nSection: Usage\n\nTo enable the option, set `experimental.turbopackLocalPostcssConfig` to `true` in your `next.config.ts` file.", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    turbopackLocalPostcssConfig: true,\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 86, "heading_path": "Usage > Usage", "breadcrumbs": "turbopackLocalPostcssConfig > Usage > Usage"}, {"id": "bec2feafe8ee8a7c", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackLocalPostcssConfig", "page_title": "turbopackLocalPostcssConfig", "page_type": "reference", "page_summary": "This page documents the `turbopackLocalPostcssConfig` option in Next.js configuration, which changes how Turbopack resolves `postcss.config.js` files, allowing per-directory configs to take…", "heading": "Behavior", "content": "Page: turbopackLocalPostcssConfig\nSection: Behavior\n\nThe table below shows the config resolution order for each setting:\n\n- `false` (default): Project root → CSS file's directory\n- `true`: CSS file's directory → project root\n\nWith the default behavior,…", "code_blocks": [], "chunk_position": 86, "heading_path": "Behavior > Behavior", "breadcrumbs": "turbopackLocalPostcssConfig > Behavior > Behavior"}, {"id": "46cab3400788ca22", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackLocalPostcssConfig", "page_title": "turbopackLocalPostcssConfig", "page_type": "reference", "page_summary": "This page documents the `turbopackLocalPostcssConfig` option in Next.js configuration, which changes how Turbopack resolves `postcss.config.js` files, allowing per-directory configs to take…", "heading": "Example", "content": "Page: turbopackLocalPostcssConfig\nSection: Example\n\nThis is useful for projects that need different PostCSS transforms in different directories, such as a monorepo with multiple apps or design system packages. The following directory structure…", "code_blocks": [{"language": "text", "code": "my-app/\n├── postcss.config.js          ← fallback (applied if no local config is found)\n├── app/\n│   └── page.module.css        ← uses root config\n└── packages/\n    └── ui/\n        ├──…", "filename": ""}], "chunk_position": 86, "heading_path": "Example > Example", "breadcrumbs": "turbopackLocalPostcssConfig > Example > Example"}, {"id": "d6bc2f43d1f9b315", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackLocalPostcssConfig", "page_title": "turbopackLocalPostcssConfig", "page_type": "reference", "page_summary": "This page documents the `turbopackLocalPostcssConfig` option in Next.js configuration, which changes how Turbopack resolves `postcss.config.js` files, allowing per-directory configs to take…", "heading": "Version History", "content": "Page: turbopackLocalPostcssConfig\nSection: Version History\n\nThe following table lists the version history for this feature:\n\n- `v16.3.0`: `turbopackLocalPostcssConfig` introduced.", "code_blocks": [], "chunk_position": 86, "heading_path": "Version History > Version History", "breadcrumbs": "turbopackLocalPostcssConfig > Version History > Version History"}, {"id": "a7e19a3889c9d8c9", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackMemoryEviction", "page_title": "next.config.js: turbopackMemoryEviction | Next.js", "page_type": "api", "page_summary": "Explains the experimental `turbopackMemoryEviction` option in Next.js, which controls whether Turbopack reclaims memory when the FileSystem cache is enabled, including its three possible settings and…", "heading": "Usage", "content": "Page: next.config.js: turbopackMemoryEviction | Next.js\nSection: Usage\n\n`turbopackMemoryEviction` controls whether Turbopack reclaims memory while the persistent (FileSystem) cache is enabled. After Turbopack writes a snapshot of its cache to disk, it can 'evict' the…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    turbopackMemoryEviction: 'auto',\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 87, "heading_path": "Usage > Usage", "breadcrumbs": "next.config.js: turbopackMemoryEviction | Next.js > Usage > Usage"}, {"id": "8693e7b57a5fce9a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackMemoryEviction", "page_title": "next.config.js: turbopackMemoryEviction | Next.js", "page_type": "api", "page_summary": "Explains the experimental `turbopackMemoryEviction` option in Next.js, which controls whether Turbopack reclaims memory when the FileSystem cache is enabled, including its three possible settings and…", "heading": "Version Changes", "content": "Page: next.config.js: turbopackMemoryEviction | Next.js\nSection: Version Changes\n\n| Version | Changes |\n| --- | --- |\n| `v16.3.0` | `turbopackMemoryEviction` released as experimental. |", "code_blocks": [], "chunk_position": 87, "heading_path": "Version Changes > Version Changes", "breadcrumbs": "next.config.js: turbopackMemoryEviction | Next.js > Version Changes > Version Changes"}, {"id": "69034cef0a2a1cf1", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackRustReactCompiler", "page_title": "turbopackRustReactCompiler", "page_type": "api", "page_summary": "The `experimental.turbopackRustReactCompiler` option enables the native Rust version of the React Compiler, running it directly inside Turbopack as native code instead of through Node.js with the…", "heading": "turbopackRustReactCompiler", "content": "Page: turbopackRustReactCompiler\nSection: turbopackRustReactCompiler\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on GitHub.\n\nThe `experimental.turbopackRustReactCompiler` option…", "code_blocks": [{"language": "ts", "code": "import type { NextConfig } from 'next'\n\nconst nextConfig: NextConfig = {\n  // Enable the React Compiler\n  reactCompiler: true,\n  experimental: {\n    // Use the Rust port instead of the Babel…", "filename": "next.config.ts"}], "chunk_position": 88, "heading_path": "turbopackRustReactCompiler > turbopackRustReactCompiler", "breadcrumbs": "turbopackRustReactCompiler > turbopackRustReactCompiler > turbopackRustReactCompiler"}, {"id": "07043433d6f8e157", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackRustReactCompiler", "page_title": "turbopackRustReactCompiler", "page_type": "api", "page_summary": "The `experimental.turbopackRustReactCompiler` option enables the native Rust version of the React Compiler, running it directly inside Turbopack as native code instead of through Node.js with the…", "heading": "Good to know", "content": "Page: turbopackRustReactCompiler\nSection: Good to know\n\n- This option requires `reactCompiler` to be enabled. It selects which implementation runs, but does not turn the compiler on by itself.\n- This option is only supported with Turbopack. Using it with…", "code_blocks": [], "chunk_position": 88, "heading_path": "Good to know > Good to know", "breadcrumbs": "turbopackRustReactCompiler > Good to know > Good to know"}, {"id": "09be4c4517ceb114", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopackRustReactCompiler", "page_title": "turbopackRustReactCompiler", "page_type": "api", "page_summary": "The `experimental.turbopackRustReactCompiler` option enables the native Rust version of the React Compiler, running it directly inside Turbopack as native code instead of through Node.js with the…", "heading": "Version History", "content": "Page: turbopackRustReactCompiler\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v16.3.0` | Introduced the experimental `turbopackRustReactCompiler` option for the native Rust React Compiler. |", "code_blocks": [], "chunk_position": 88, "heading_path": "Version History > Version History", "breadcrumbs": "turbopackRustReactCompiler > Version History > Version History"}, {"id": "dfaf2933c0ceedce", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/typedRoutes", "page_title": "typedRoutes", "page_type": "api", "page_summary": "Configuration option for Next.js that enables statically typed links. Requires TypeScript in the project.", "heading": "typedRoutes", "content": "Page: typedRoutes\nSection: typedRoutes\n\nNote: This option has been marked as stable, so you should use `typedRoutes` instead of `experimental.typedRoutes`.\n\nSupport for statically typed links. This feature requires using TypeScript in your…", "code_blocks": [{"language": "js", "code": "/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  typedRoutes: true,\n}\n \nmodule.exports = nextConfig", "filename": "next.config.js"}], "chunk_position": 89, "heading_path": "typedRoutes > typedRoutes", "breadcrumbs": "typedRoutes > typedRoutes > typedRoutes"}, {"id": "a54c447952973761", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/typescript", "page_title": "typescript", "page_type": "api", "page_summary": "Configure TypeScript behavior with the `typescript` option in `next.config.js`.", "heading": "typescript", "content": "Page: typescript\nSection: typescript\n\nConfigure TypeScript behavior with the `typescript` option in `next.config.js`:", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  typescript: {\n    ignoreBuildErrors: false,\n    tsconfigPath: 'tsconfig.json',\n  },\n}", "filename": "next.config.js"}], "chunk_position": 90, "heading_path": "typescript > typescript", "breadcrumbs": "typescript > typescript > typescript"}, {"id": "63382632651f3d69", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/typescript", "page_title": "typescript", "page_type": "api", "page_summary": "Configure TypeScript behavior with the `typescript` option in `next.config.js`.", "heading": "ignoreBuildErrors", "content": "Page: typescript\nSection: ignoreBuildErrors\n\nNext.js fails your **production build** (`next build`) when TypeScript errors are present in your project.\n\nIf you'd like Next.js to dangerously produce production code even when your application has…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  typescript: {\n    // !! WARN !!\n    // Dangerously allow production builds to successfully complete even if\n    // your project has type errors.\n    // !! WARN !!…", "filename": "next.config.js"}], "chunk_position": 90, "heading_path": "ignoreBuildErrors > ignoreBuildErrors", "breadcrumbs": "typescript > ignoreBuildErrors > ignoreBuildErrors"}, {"id": "8e12914b0ec8ea78", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/typescript", "page_title": "typescript", "page_type": "api", "page_summary": "Configure TypeScript behavior with the `typescript` option in `next.config.js`.", "heading": "tsconfigPath", "content": "Page: typescript\nSection: tsconfigPath\n\nUse a different TypeScript configuration file for builds or tooling:\n\nSee the [TypeScript configuration](/docs/app/api-reference/config/typescript#custom-tsconfig-path) page for more details.", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  typescript: {\n    tsconfigPath: 'tsconfig.build.json',\n  },\n}", "filename": "next.config.js"}], "chunk_position": 90, "heading_path": "tsconfigPath > tsconfigPath", "breadcrumbs": "typescript > tsconfigPath > tsconfigPath"}, {"id": "14ef85fe3744257e", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/urlImports", "page_title": "next.config.js: urlImports | Next.js", "page_type": "reference", "page_summary": "Documentation for the experimental urlImports feature in Next.js, which allows importing modules directly from external URLs, with configuration, security model, lockfile behavior, and examples.", "heading": "urlImports", "content": "Page: next.config.js: urlImports | Next.js\nSection: urlImports\n\nURL imports are an experimental feature that allows you to import modules directly from external servers (instead of from the local disk).\n\n> **Warning** : Only use domains that you trust to download…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  experimental: {\n    urlImports: ['https://example.com/assets/', 'https://cdn.skypack.dev'],\n  },\n}", "filename": "next.config.js"}, {"language": "javascript", "code": "import { a, b, c } from 'https://example.com/assets/some/module.js'", "filename": ""}], "chunk_position": 91, "heading_path": "urlImports > urlImports", "breadcrumbs": "next.config.js: urlImports | Next.js > urlImports > urlImports"}, {"id": "9cda834ee17a3f61", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/urlImports", "page_title": "next.config.js: urlImports | Next.js", "page_type": "reference", "page_summary": "Documentation for the experimental urlImports feature in Next.js, which allows importing modules directly from external URLs, with configuration, security model, lockfile behavior, and examples.", "heading": "Security Model", "content": "Page: next.config.js: urlImports | Next.js\nSection: Security Model\n\nThis feature is being designed with **security as the top priority** . To start, we added an experimental flag forcing you to explicitly allow the domains you accept URL imports from. We're working…", "code_blocks": [], "chunk_position": 91, "heading_path": "Security Model > Security Model", "breadcrumbs": "next.config.js: urlImports | Next.js > Security Model > Security Model"}, {"id": "57db046fb1a79c91", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/urlImports", "page_title": "next.config.js: urlImports | Next.js", "page_type": "reference", "page_summary": "Documentation for the experimental urlImports feature in Next.js, which allows importing modules directly from external URLs, with configuration, security model, lockfile behavior, and examples.", "heading": "Lockfile", "content": "Page: next.config.js: urlImports | Next.js\nSection: Lockfile\n\nWhen using URL imports, Next.js will create a `next.lock` directory containing a lockfile and fetched assets. This directory **must be committed to Git** , not ignored by `.gitignore`.\n\n- When…", "code_blocks": [], "chunk_position": 91, "heading_path": "Lockfile > Lockfile", "breadcrumbs": "next.config.js: urlImports | Next.js > Lockfile > Lockfile"}, {"id": "36765e2527ed53a0", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/urlImports", "page_title": "next.config.js: urlImports | Next.js", "page_type": "reference", "page_summary": "Documentation for the experimental urlImports feature in Next.js, which allows importing modules directly from external URLs, with configuration, security model, lockfile behavior, and examples.", "heading": "Examples", "content": "Page: next.config.js: urlImports | Next.js\nSection: Examples\n\n###### Skypack\n\n###### Static Image Imports\n\n###### URLs in CSS\n\n###### Asset Imports", "code_blocks": [{"language": "javascript", "code": "import confetti from 'https://cdn.skypack.dev/canvas-confetti'\nimport { useEffect } from 'react'\n \nexport default () => {\n  useEffect(() => {\n    confetti()\n  })\n  return <p>Hello</p>\n}", "filename": ""}, {"language": "javascript", "code": "import Image from 'next/image'\nimport logo from 'https://example.com/assets/logo.png'\n \nexport default () => (\n  <div>\n    <Image src={logo} placeholder=\"blur\" />\n  </div>\n)", "filename": ""}, {"language": "css", "code": ".className {\n  background: url('https://example.com/assets/hero.jpg');\n}", "filename": ""}, {"language": "javascript", "code": "const logo = new URL('https://example.com/assets/file.txt', import.meta.url)\n \nconsole.log(logo.pathname)\n \n// prints \"/_next/static/media/file.a9727b5d.txt\"", "filename": ""}], "chunk_position": 91, "heading_path": "Examples > Examples", "breadcrumbs": "next.config.js: urlImports | Next.js > Examples > Examples"}, {"id": "d04d5906d425f2bb", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useLightningcss", "page_title": "useLightningcss", "page_type": "api", "page_summary": "Experimental support for using Lightning CSS with webpack, and configuration options for controlling CSS feature transpilation.", "heading": "useLightningcss", "content": "Page: useLightningcss\nSection: useLightningcss\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on GitHub.\n\nExperimental support for using Lightning CSS with…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    useLightningcss: false, // default, ignored on Turbopack\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 92, "heading_path": "useLightningcss > useLightningcss", "breadcrumbs": "useLightningcss > useLightningcss > useLightningcss"}, {"id": "a2156e8d5779e78e", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useLightningcss", "page_title": "useLightningcss", "page_type": "api", "page_summary": "Experimental support for using Lightning CSS with webpack, and configuration options for controlling CSS feature transpilation.", "heading": "lightningCssFeatures", "content": "Page: useLightningcss\nSection: lightningCssFeatures\n\nBy default, Lightning CSS decides which CSS features to transpile based on your browserslist targets. The `lightningCssFeatures` option lets you override this by forcing specific features to always…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    useLightningcss: true,\n    lightningCssFeatures: {\n      // Always transpile these features, even if…", "filename": "next.config.ts"}], "chunk_position": 92, "heading_path": "lightningCssFeatures > lightningCssFeatures", "breadcrumbs": "useLightningcss > lightningCssFeatures > lightningCssFeatures"}, {"id": "da60e0b18486951d", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useLightningcss", "page_title": "useLightningcss", "page_type": "api", "page_summary": "Experimental support for using Lightning CSS with webpack, and configuration options for controlling CSS feature transpilation.", "heading": "Options", "content": "Page: useLightningcss\nSection: Options\n\n| Option | Type | Description |\n| --- | --- | --- |\n| `include` | `string[]` | Features to always transpile, regardless of browser targets. |\n| `exclude` | `string[]` | Features to never transpile,…", "code_blocks": [], "chunk_position": 92, "heading_path": "Options > Options", "breadcrumbs": "useLightningcss > Options > Options"}, {"id": "2ea48557dc7f1a41", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useLightningcss", "page_title": "useLightningcss", "page_type": "api", "page_summary": "Experimental support for using Lightning CSS with webpack, and configuration options for controlling CSS feature transpilation.", "heading": "Available features", "content": "Page: useLightningcss\nSection: Available features\n\nIndividual features:\n\n| Feature name | Description |\n| --- | --- |\n| `nesting` | CSS Nesting |\n| `not-selector-list` | `:not` with multiple selectors |\n| `dir-selector` | `:dir()` selector |\n|…", "code_blocks": [], "chunk_position": 92, "heading_path": "Available features > Available features", "breadcrumbs": "useLightningcss > Available features > Available features"}, {"id": "5aa8c019d8f76b03", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useLightningcss", "page_title": "useLightningcss", "page_type": "api", "page_summary": "Experimental support for using Lightning CSS with webpack, and configuration options for controlling CSS feature transpilation.", "heading": "Version History", "content": "Page: useLightningcss\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `16.2.0` | `lightningCssFeatures` added. |\n| `15.1.0` | Support for `useSwcCss` was removed from Turbopack. |\n| `14.2.0` | Turbopack's default CSS processor was…", "code_blocks": [], "chunk_position": 92, "heading_path": "Version History > Version History", "breadcrumbs": "useLightningcss > Version History > Version History"}, {"id": "3818595833250cec", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useOffline", "page_title": "next.config.js: useOffline | Next.js", "page_type": "reference", "page_summary": "This page documents the experimental `useOffline` configuration option in Next.js, which enables offline connectivity detection, automatic retry of failed navigation, prefetch, and Server Action…", "heading": "useOffline", "content": "Page: next.config.js: useOffline | Next.js\nSection: useOffline\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on GitHub.\n\nThe `useOffline` configuration option enables offline…", "code_blocks": [{"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    useOffline: true,\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 93, "heading_path": "useOffline > useOffline", "breadcrumbs": "next.config.js: useOffline | Next.js > useOffline > useOffline"}, {"id": "d242d9cfa8a40704", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useOffline", "page_title": "next.config.js: useOffline | Next.js", "page_type": "reference", "page_summary": "This page documents the experimental `useOffline` configuration option in Next.js, which enables offline connectivity detection, automatic retry of failed navigation, prefetch, and Server Action…", "heading": "How retry works", "content": "Page: next.config.js: useOffline | Next.js\nSection: How retry works\n\nThe offline state is entered through one of two paths:\n\n- **Browser event.** Next.js registers a `window.addEventListener('offline', ...)` listener. When the OS reports the network interface as down,…", "code_blocks": [], "chunk_position": 93, "heading_path": "How retry works > How retry works", "breadcrumbs": "next.config.js: useOffline | Next.js > How retry works > How retry works"}, {"id": "2cd445edae824f02", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useOffline", "page_title": "next.config.js: useOffline | Next.js", "page_type": "reference", "page_summary": "This page documents the experimental `useOffline` configuration option in Next.js, which enables offline connectivity detection, automatic retry of failed navigation, prefetch, and Server Action…", "heading": "The connectivity check", "content": "Page: next.config.js: useOffline | Next.js\nSection: The connectivity check\n\nEach check issues a single `HEAD` request to the current page's URL with the RSC header set, the same endpoint navigations use. The request is aborted after 200 ms.\n\nTwo outcomes count as…", "code_blocks": [], "chunk_position": 93, "heading_path": "The connectivity check > The connectivity check", "breadcrumbs": "next.config.js: useOffline | Next.js > The connectivity check > The connectivity check"}, {"id": "3a8e8861478cebcf", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useOffline", "page_title": "next.config.js: useOffline | Next.js", "page_type": "reference", "page_summary": "This page documents the experimental `useOffline` configuration option in Next.js, which enables offline connectivity detection, automatic retry of failed navigation, prefetch, and Server Action…", "heading": "Backoff", "content": "Page: next.config.js: useOffline | Next.js\nSection: Backoff\n\nDelays between checks are stepped, not exponential, and capped at 3 seconds:\n\n| Attempt | Delay before next check |\n| --- | --- |\n| 1 | 500 ms |\n| 2 | 1 s |\n| 3 | 2 s |\n| 4 and after | 3 s |\n\nThe…", "code_blocks": [], "chunk_position": 93, "heading_path": "Backoff > Backoff", "breadcrumbs": "next.config.js: useOffline | Next.js > Backoff > Backoff"}, {"id": "d09c708490d0c987", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useOffline", "page_title": "next.config.js: useOffline | Next.js", "page_type": "reference", "page_summary": "This page documents the experimental `useOffline` configuration option in Next.js, which enables offline connectivity detection, automatic retry of failed navigation, prefetch, and Server Action…", "heading": "Giving up", "content": "Page: next.config.js: useOffline | Next.js\nSection: Giving up\n\nThe polling loop never gives up on its own. It continues at the 3-second cap until a check succeeds or the page unloads. A device that goes offline for hours and then regains connectivity will have…", "code_blocks": [], "chunk_position": 93, "heading_path": "Giving up > Giving up", "breadcrumbs": "next.config.js: useOffline | Next.js > Giving up > Giving up"}, {"id": "e85491830c924449", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useOffline", "page_title": "next.config.js: useOffline | Next.js", "page_type": "reference", "page_summary": "This page documents the experimental `useOffline` configuration option in Next.js, which enables offline connectivity detection, automatic retry of failed navigation, prefetch, and Server Action…", "heading": "Retry of framework requests", "content": "Page: next.config.js: useOffline | Next.js\nSection: Retry of framework requests\n\nWhile the offline state is active, any navigation, prefetch, or Server Action waits for the next connectivity check to succeed, whether it was newly issued or already in flight when the connection…", "code_blocks": [], "chunk_position": 93, "heading_path": "Retry of framework requests > Retry of framework requests", "breadcrumbs": "next.config.js: useOffline | Next.js > Retry of framework requests > Retry of framework requests"}, {"id": "d9fcc1f7e71c5350", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useOffline", "page_title": "next.config.js: useOffline | Next.js", "page_type": "reference", "page_summary": "This page documents the experimental `useOffline` configuration option in Next.js, which enables offline connectivity detection, automatic retry of failed navigation, prefetch, and Server Action…", "heading": "Traffic at reconnection", "content": "Page: next.config.js: useOffline | Next.js\nSection: Traffic at reconnection\n\nA single client does not produce a runaway burst of traffic against its origin:\n\n- While the client is offline, a failed `fetch()` rejects locally at the browser's network layer. The request never…", "code_blocks": [], "chunk_position": 93, "heading_path": "Traffic at reconnection > Traffic at reconnection", "breadcrumbs": "next.config.js: useOffline | Next.js > Traffic at reconnection > Traffic at reconnection"}, {"id": "2cee6406b8ac0471", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useOffline", "page_title": "next.config.js: useOffline | Next.js", "page_type": "reference", "page_summary": "This page documents the experimental `useOffline` configuration option in Next.js, which enables offline connectivity detection, automatic retry of failed navigation, prefetch, and Server Action…", "heading": "Version History", "content": "Page: next.config.js: useOffline | Next.js\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v16.x.0` | `experimental.useOffline` configuration option introduced. |", "code_blocks": [], "chunk_position": 93, "heading_path": "Version History > Version History", "breadcrumbs": "next.config.js: useOffline | Next.js > Version History > Version History"}, {"id": "d8f6de14ae14c71a", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useTypeScriptCli", "page_title": "next.config.js: useTypeScriptCli | Next.js", "page_type": "api", "page_summary": "Documents the experimental `experimental.useTypeScriptCli` configuration option, which controls whether `next build` uses the project-local `tsc` CLI or the TypeScript JavaScript compiler API for…", "heading": "useTypeScriptCli", "content": "Page: next.config.js: useTypeScriptCli | Next.js\nSection: useTypeScriptCli\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on [GitHub](https://github.com/vercel/next.js/issues).\n\nBy…", "code_blocks": [{"language": "bash", "code": "pnpm add -D typescript@^7", "filename": ""}, {"language": "typescript", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    useTypeScriptCli: false,\n  },\n}\n \nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 94, "heading_path": "useTypeScriptCli > useTypeScriptCli", "breadcrumbs": "next.config.js: useTypeScriptCli | Next.js > useTypeScriptCli > useTypeScriptCli"}, {"id": "cc617a5566359d90", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/useTypeScriptCli", "page_title": "next.config.js: useTypeScriptCli | Next.js", "page_type": "api", "page_summary": "Documents the experimental `experimental.useTypeScriptCli` configuration option, which controls whether `next build` uses the project-local `tsc` CLI or the TypeScript JavaScript compiler API for…", "heading": "Behavior", "content": "Page: next.config.js: useTypeScriptCli | Next.js\nSection: Behavior\n\n- Next.js continues to generate `next-env.d.ts` and route types and to apply its recommended `tsconfig` settings before running the checker.\n\n- TypeScript diagnostics are printed directly from `tsc`.…", "code_blocks": [], "chunk_position": 94, "heading_path": "Behavior > Behavior", "breadcrumbs": "next.config.js: useTypeScriptCli | Next.js > Behavior > Behavior"}, {"id": "db6e5bc74c923c5f", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/webVitalsAttribution", "page_title": "webVitalsAttribution", "page_type": "reference", "page_summary": "Explains the experimental webVitalsAttribution option in next.config.js, which enables per-metric Web Vitals attribution to help pinpoint the source of Web Vitals issues.", "heading": "webVitalsAttribution", "content": "Page: webVitalsAttribution\nSection: webVitalsAttribution\n\nThis feature is currently experimental and subject to change, it's not recommended for production. Try it out and share your feedback on [GitHub](https://github.com/vercel/next.js/issues).\n\nWhen…", "code_blocks": [{"language": "js", "code": "module.exports = {\n  experimental: {\n    webVitalsAttribution: ['CLS', 'LCP'],\n  },\n}", "filename": "next.config.js"}], "chunk_position": 95, "heading_path": "webVitalsAttribution > webVitalsAttribution", "breadcrumbs": "webVitalsAttribution > webVitalsAttribution > webVitalsAttribution"}, {"id": "9c43dd8138734485", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/webpack", "page_title": "Custom Webpack Config", "page_type": "api", "page_summary": "Describes how to customize the webpack configuration in Next.js using the `webpack` option in `next.config.js`, including the properties available in the second argument and an example of extending…", "heading": "Custom Webpack Config", "content": "Page: Custom Webpack Config\nSection: Custom Webpack Config\n\n**Good to know** : changes to webpack config are not covered by semver so proceed at your own risk\n\nBefore continuing to add custom webpack configuration to your application make sure Next.js doesn't…", "code_blocks": [{"language": "javascript", "code": "module.exports = {\n  webpack: (\n    config,\n    { buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }\n  ) => {\n    // Important: return the modified config\n    return config\n  },\n}", "filename": "next.config.js"}, {"language": "javascript", "code": "// Example config for adding a loader that depends on babel-loader\n// This source was taken from the @next/mdx plugin source:\n//…", "filename": ""}], "chunk_position": 96, "heading_path": "Custom Webpack Config > Custom Webpack Config", "breadcrumbs": "Custom Webpack Config > Custom Webpack Config > Custom Webpack Config"}, {"id": "7ceec8eade829057", "url": "https://nextjs.org/docs/app/api-reference/config/next-config-js/webpack", "page_title": "Custom Webpack Config", "page_type": "api", "page_summary": "Describes how to customize the webpack configuration in Next.js using the `webpack` option in `next.config.js`, including the properties available in the second argument and an example of extending…", "heading": "nextRuntime", "content": "Page: Custom Webpack Config\nSection: nextRuntime\n\nNotice that `isServer` is `true` when `nextRuntime` is `\"edge\"` or `\"nodejs\"`, `nextRuntime` `\"edge\"` is currently for proxy and Server Components in edge runtime only.", "code_blocks": [], "chunk_position": 96, "heading_path": "nextRuntime > nextRuntime", "breadcrumbs": "Custom Webpack Config > nextRuntime > nextRuntime"}, {"id": "36b44beb1ae5caeb", "url": "https://nextjs.org/docs/app/api-reference/config/typescript", "page_title": "Configuration: TypeScript | Next.js", "page_type": "reference", "page_summary": "Extraction fallback content.", "heading": "Configuration: TypeScript | Next.js", "content": "Page: Configuration: TypeScript | Next.js\nSection: Configuration: TypeScript | Next.js\n\nThis page is also available as Markdown: request this page's URL with an `Accept: text/markdown` header.   For an index of  Next.js documentation , see  [/docs/llms.txt](/docs/llms.txt).Copy page\n\n##### TypeScript\n\nLast updated  August 3, 2026\n\n\nNext.js comes with built-in TypeScript, automatically installing the necessary packages and configuring the proper settings when you create a new project with `create-next-app`.\n\n\n\n\nTo add TypeScript to an existing project, rename a file to `.ts` / `.tsx`. Run `next dev` and `next build` to automatically install the necessary dependencies and add a `tsconfig.json` file with the recommended config options.\n\n\n\n\n> **Good to know** : If you already have a `jsconfig.json` file, copy the `paths` compiler option from the old `jsconfig.json` into the new `tsconfig.json` file, and delete the old `jsconfig.json` file.\n\n\n\n\n##### Using TypeScript 7\n\n\n\n\n[TypeScript 7](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/) does not currently provide the JavaScript compiler API. To use TypeScript 7 during `next build`, install it in your project:\n\n\npnpmnpmyarnbunTerminal\n \n \n \n\n\nNext.js uses the project-local `tsc` CLI by default, so no additional configuration is required. To use the JavaScript compiler API instead, set [`experimental.useTypeScriptCli`](/docs/app/api-reference/config/next-config-js/useTypeScriptCli) to `false`.\n\n\n\n\n> **Good to know** :\n> \n> \n> \n> \n> \n> \n> - CLI type checking prints the native `tsc` diagnostics. It does not apply Next.js-specific code frames or rewrite errors for routes, pages, layouts, or route handlers.\n> \n> - The CLI checks the complete project selected by your `tsconfig` file. This includes test files and `.next/dev/types` when they are included by that configuration. [`next build --debug-build-paths`](/docs/app/api-reference/cli/next#next-build-options) does not narrow the files that are type checked and produces a warning when used with this option.\n> \n> - [`typescript.tsconfigPath`](#custom-tsconfig-path) continues to select the configuration passed to `tsc`. [`typescript.ignoreBuildErrors`](#disabling-typescript-errors-in-production) skips the type-checking step, including the CLI checker.\n> \n> - `experimental.useTypeScriptCli` is experimental and its behavior may change.\n\n\n\n\n##### IDE Plugin\n\n\n\nNext.js includes a custom TypeScript plugin and type checker, which VSCode and other code editors can use for advanced type-checking and auto-completion.\n\n\n\nYou can enable the plugin in VS Code by:\n\n\n\n\n\n- Opening the command palette (`Ctrl/⌘` + `Shift` + `P`)\n\n- Searching for \"TypeScript: Select TypeScript Version\"\n\n- Selecting \"Use Workspace Version\"\n\n\n<img src=\"/_next/image?url=https%3A%2F%2Fh8DxKfmAPhn8O0p3.public.blob.vercel-storage.com%2Fdocs%2Flight%2Ftypescript-command-palette.png&w=3840&q=75\" alt=\"TypeScript Command Palette\"><img src=\"/_next/image?url=https%3A%2F%2Fh8DxKfmAPhn8O0p3.public.blob.vercel-storage.com%2Fdocs%2Fdark%2Ftypescript-command-palette.png&w=3840&q=75\" alt=\"TypeScript Command Palette\">\n\nNow, when editing files, the custom plugin will be enabled. By default, the project-local `tsc` CLI is used when running `next build`. Set [`experimental.useTypeScriptCli`](#using-typescript-7) to `false` to use the custom type checker instead.\n\n\n\nThe TypeScript plugin can help with:\n\n\n\n\n\n- Warning if invalid values for [segment config options](/docs/app/api-reference/file-conventions/route-segment-config) are passed.\n\n- Showing available options and in-context documentation.\n\n- Ensuring the `'use client'` directive is used correctly.\n\n- Ensuring client hooks (like `useState`) are only used in Client Components.\n\n\n\n\n> **🎥 Watch:**  Learn about the built-in TypeScript plugin → [YouTube (3 minutes)](https://www.youtube.com/watch?v=pqMqn9fKEf8)\n\n\n\n##### End-to-End Type Safety\n\n\n\nThe Next.js App Router has  **enhanced type safety** . This includes:\n\n\n\n\n\n- **No serialization of data between fetching function and page** : You can `fetch` directly in components, layouts, and pages on the server. This data  *does not*  need to be serialized (converted to a string) to be passed to the client side for consumption in React. Instead, since `app` uses Server Components by default, we can use values like `Date`, `Map`, `Set`, and more without any extra steps. Previously, you needed to manually type the boundary between server and client with Next.js-specific types.\n\n- **Streamlined data flow between components** : With the removal of `_app` in favor of root layouts, it is now easier to visualize the data flow between components and pages. Previously, data flowing between individual `pages` and `_app` were difficult to type and could introduce confusing bugs. With [colocated data fetching](/docs/app/getting-started/fetching-data) in the App Router, this is no longer an issue.\n\n\n\n\n[Data Fetching in Next.js](/docs/app/getting-started/fetching-data) now provides as close to end-to-end type safety as possible without being prescriptive about your database or content provider selection.\n\n\n\nWe're able to type the response data as you would expect with normal TypeScript. For example:\n\napp/page.tsxTypeScriptJavaScriptTypeScript\n\nFor  *complete*  end-to-end type safety, this also requires your database or content provider to support TypeScript. This could be through using an [ORM](https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping) or type-safe query builder.\n\n\n\n##### Route-Aware Type Helpers\n\n\n\nNext.js generates global helpers for App Router route types. These are available without imports and are generated during `next dev`, `next build`, or via [`next typegen`](/docs/app/api-reference/cli/next#next-typegen-options):\n\n\n\n\n\n- [`PageProps`](/docs/app/api-reference/file-conventions/page#page-props-helper)\n\n- [`LayoutProps`](/docs/app/api-reference/file-conventions/layout#layout-props-helper)\n\n- [`RouteContext`](/docs/app/api-reference/file-conventions/route#route-context-helper)\n\n\n\n\n\n##### `next-env.d.ts`\n\n\n\n\nNext.js generates a `next-env.d.ts` file in your project root. This file references Next.js type definitions, allowing TypeScript to recognize non-code imports (images, stylesheets, etc.) and Next.js-specific types.\n\n\n\n\nRunning `next dev`, `next build`, or [`next typegen`](/docs/app/api-reference/cli/next#next-typegen-options) regenerates this file.\n\n\n\n\n> **Good to know** :\n> \n> \n> \n> \n> \n> \n> - `next-env.d.ts` is managed by Next.js. Its contents are an implementation detail and may change over time. Add it to `.gitignore`. If your project already tracks the file, remove it from Git. Do not edit this file manually.\n> \n> - The file must be in your `tsconfig.json` `include` array (`create-next-app` does this automatically).\n\n\n\n\n##### Examples\n\n\n\n\n###### Type Checking Next.js Configuration Files\n\n\n\n\nYou can use TypeScript and import types in your Next.js configuration by using `next.config.ts`.\n\n\nnext.config.ts\n\n\nModule resolution in `next.config.ts` is currently limited to CommonJS. However, ECMAScript Modules (ESM) syntax is available when [using Node.js native TypeScript resolver](#using-nodejs-native-typescript-resolver-for-nextconfigts) for Node.js v22.10.0 and higher.\n\n\n\n\nWhen using the `next.config.js` file, you can add some type checking in your IDE using JSDoc as below:\n\n\nnext.config.js\n\n\n###### Using Node.js Native TypeScript Resolver for `next.config.ts`\n\n\n\n\n> **Note** : Available on Node.js v22.10.0+ and only when the feature is enabled. Next.js does not enable it.\n\n\n\n\nNext.js detects the [Node.js native TypeScript resolver](https://nodejs.org/api/typescript.html) via [`process.features.typescript`](https://nodejs.org/api/process.html#processfeaturestypescript), added in  **v22.10.0** . When present, `next.config.ts` can use native ESM, including top‑level `await` and dynamic `import()`. This mechanism inherits the capabilities and limitations of Node's resolver.\n\n\n\n\nIn Node.js versions  **v22.18.0+** , `process.features.typescript` is enabled by default. For versions between  **v22.10.0**  and  **22.17.x** , opt in with `NODE_OPTIONS=--experimental-transform-types`:\n\n\nTerminal\n\n\n###### For CommonJS Projects (Default)\n\n\n\n\nAlthough `next.config.ts` supports native ESM syntax in CommonJS projects, Node.js will still assume `next.config.ts` is a CommonJS file by default, resulting in Node.js reparsing the file as ESM when module syntax is detected. Therefore, we recommend using the `next.config.mts` file for CommonJS projects to explicitly indicate it's an ESM module:\n\n\nnext.config.mts\n\n\n###### For ESM Projects\n\n\n\n\nWhen `\"type\"` is set to `\"module\"` in `package.json`, your project uses ESM. Learn more about this setting [in the Node.js docs](https://nodejs.org/api/packages.html#type). In this case, you can write `next.config.ts` directly with ESM syntax.\n\n\n\n\n> **Good to know** : When using `\"type\": \"module\"` in your `package.json`, all `.js` and `.ts` files in your project are treated as ESM modules by default. You may need to rename files with CommonJS syntax to `.cjs` or `.cts` extensions if needed.\n\n\n\n\n###### Statically Typed Links\n\n\n\n\nNext.js can statically type links to prevent typos and other errors when using `next/link`, improving type safety when navigating between pages.\n\n\n\n\nWorks in both the Pages and App Router for the `href` prop in `next/link`. In the App Router, it also types `next/navigation` methods like `push`, `replace`, and `prefetch`. It does not type `next/router` methods in Pages Router.\n\n\n\n\nLiteral `href` strings are validated, while non-literal `href`s may require a cast with `as Route`.\n\n\n\n\nTo opt-into this feature, `typedRoutes` needs to be enabled and the project needs to be using TypeScript.\n\n\nnext.config.ts\n\n\nNext.js will generate a link definition in `.next/types` that contains information about all existing routes in your application, which TypeScript can then use to provide feedback in your editor about invalid links.\n\n\n\n\n> **Good to know** : If you set up your project without `create-next-app`, ensure the generated Next.js types are included by adding `.next/types/**/*.ts` to the `include` array in your `tsconfig.json`:\n\n\n \ntsconfig.json\n \n\n\nCurrently, support includes any string literal, including dynamic segments. For non-literal strings, you need to manually cast with `as Route`. The example below shows both `next/link` and `next/navigation` usage:\n\n\napp/example-client.tsx\n\n\nThe same applies for redirecting routes defined by proxy:\n\n\nproxy.ts\napp/some/page.tsx\n\n\nTo accept `href` in a custom component wrapping `next/link`, use a generic:\n\n\n\n\n\nYou can also type a simple data structure and iterate to render links:\n\n\ncomponents/nav-items.ts\n\n\nThen, map over the items to render `Link`s:\n\n\ncomponents/nav.tsx\n\n\n> **How does it work?** \n> \n> \n> \n> \n> When running, `next typegen`, `next dev` or `next build`, Next.js generates a hidden `.d.ts` file inside `.next` that contains information about all existing routes in your application (all valid routes as the `href` type of `Link`). This `.d.ts` file is included in `tsconfig.json` and the TypeScript compiler will check that `.d.ts` and provide feedback in your editor about invalid links.\n\n\n\n\n###### Type IntelliSense for Environment Variables\n\n\n\n\nDuring development, Next.js generates a `.d.ts` file in `.next/types` that contains information about the loaded environment variables for your editor's IntelliSense. If the same environment variable key is defined in multiple files, it is deduplicated according to the [Environment Variable Load Order](/docs/app/guides/environment-variables#environment-variable-load-order).\n\n\n\n\nTo opt-into this feature, `experimental.typedEnv` needs to be enabled and the project needs to be using TypeScript.\n\n\nnext.config.ts\n\n\n> **Good to know** : Types are generated based on the environment variables loaded at development runtime, which excludes variables from `.env.production*` files by default. To include production-specific variables, run `next dev` with `NODE_ENV=production`.\n\n\n\n\n###### With Async Server Components\n\n\n\nTo use an `async` Server Component with TypeScript, ensure you are using TypeScript `5.1.3` or higher and `@types/react` `18.2.8` or higher.\n\n\n\nIf you are using an older version of TypeScript, you may see a `'Promise<Element>' is not a valid JSX element` type error. Updating to the latest version of TypeScript and `@types/react` should resolve this issue.\n\n\n \n\n\n###### Incremental type checking\n\n\n\n\nSince `v10.2.1` Next.js supports [incremental type checking](https://www.typescriptlang.org/tsconfig#incremental) when enabled in your `tsconfig.json`, this can help speed up type checking in larger applications.\n\n\n\n\n###### Custom `tsconfig` path\n\n\n\n\nIn some cases, you might want to use a different TypeScript configuration for builds or tooling. To do that, set `typescript.tsconfigPath` in `next.config.ts` to point Next.js to another `tsconfig` file.\n\n\nnext.config.ts\n\n\nFor example, switch to a different config for production builds:\n\n\nnext.config.ts\nWhy you might use a separate `tsconfig` for builds\n\nYou might need to relax checks in scenarios like monorepos, where the build also validates shared dependencies that don't match your project's standards, or when loosening checks in CI to continue delivering while migrating locally to stricter TypeScript settings (and still wanting your IDE to highlight misuse).\n\n\n\nFor example, if your project uses `useUnknownInCatchVariables` but some monorepo dependencies still assume `any`:\n\ntsconfig.build.json\n\nThis keeps your editor strict via `tsconfig.json` while allowing the production build to use relaxed settings.\n\n\n\n\n> **Good to know** :\n> \n> \n> \n> \n> \n> \n> - IDEs typically read `tsconfig.json` for diagnostics and IntelliSense, so you can still see IDE warnings while production builds use the alternate config. Mirror critical options if you want parity in the editor.\n> \n> - In development, only `tsconfig.json` is watched for changes. If you edit a different file name via `typescript.tsconfigPath`, restart the dev server to apply changes.\n> \n> - The configured file is used in `next dev`, `next build`, and `next typegen`.\n\n\n\n\n###### Disabling TypeScript errors in production\n\n\n\n\nNext.js fails your  **production build**  (`next build`) when TypeScript errors are present in your project.\n\n\n\n\nIf you'd like Next.js to dangerously produce production code even when your application has errors, you can disable the built-in type checking step.\n\n\n\n\nIf disabled, be sure you are running type checks as part of your build or deploy process, otherwise this can be very dangerous.\n\n\n\n\nOpen `next.config.ts` and enable the `ignoreBuildErrors` option in the [`typescript`](/docs/app/api-reference/config/next-config-js/typescript) config:\n\n\nnext.config.ts\n\n\n> **Good to know** : You can run `tsc --noEmit` to check for TypeScript errors yourself before building. This is useful for CI/CD pipelines where you'd like to check for TypeScript errors before deploying.\n\n\n\n\n###### Custom type declarations\n\n\n\n\nWhen you need to declare custom types, you might be tempted to modify `next-env.d.ts`. However, this file is automatically generated, so any changes you make will be overwritten. Instead, you should create a new file, let's call it `new-types.d.ts`, and reference it in your `tsconfig.json`:\n\n\ntsconfig.json\n\n\n##### Version Changes\n\n\n\n\n\n\n\n| Version | Changes |\n| --- | --- |\n\n\n\n\n| `v15.0.0` | [`next.config.ts`](#type-checking-nextjs-configuration-files) support added for TypeScript projects. |\n| `v13.2.0` | Statically typed links are available in beta. |\n| `v12.0.0` | [SWC](/docs/architecture/nextjs-compiler) is now used by default to compile TypeScript and TSX for faster builds. |\n| `v10.2.1` | [Incremental type checking](https://www.typescriptlang.org/tsconfig#incremental) support added when enabled in your `tsconfig.json`. |\n\n\n\n\n\nWas this helpful?\n\nsupported.Send", "code_blocks": [{"language": "carbon", "code": "pnpm add -D typescript@^7", "filename": ""}, {"language": "gdscript", "code": "async function getData() {\n  const res = await fetch('https://api.example.com/...')\n  // The return value is *not* serialized\n  // You can return Date, Map, Set, etc.\n  return res.json()\n}\n \nexport default async function Page() {\n  const name = await getData()\n \n  return '...'\n}", "filename": ""}, {"language": "python", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  /* config options here */\n}\n \nexport default nextConfig", "filename": ""}, {"language": "gdscript", "code": "// @ts-check\n \n/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  /* config options here */\n}\n \nmodule.exports = nextConfig", "filename": ""}, {"language": "carbon", "code": "NODE_OPTIONS=--experimental-transform-types next <command>", "filename": ""}, {"language": "python", "code": "import type { NextConfig } from 'next'\n \n// Top-level await and dynamic import are supported\nconst flags = await import('./flags.js').then((m) => m.default ?? m)\n \nconst nextConfig: NextConfig = {\n  /* config options here */\n  typedRoutes: Boolean(flags?.typedRoutes),\n}\n \nexport default nextConfig", "filename": ""}, {"language": "python", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  typedRoutes: true,\n}\n \nexport default nextConfig", "filename": ""}, {"language": "carbon", "code": "{\n  \"include\": [\n    \"next-env.d.ts\",\n    \".next/types/**/*.ts\",\n    \"**/*.ts\",\n    \"**/*.tsx\"\n  ],\n  \"exclude\": [\"node_modules\"]\n}", "filename": ""}, {"language": "python", "code": "'use client'\n \nimport type { Route } from 'next'\nimport Link from 'next/link'\nimport { useRouter } from 'next/navigation'\n \nexport default function Example() {\n  const router = useRouter()\n  const slug = 'nextjs'\n \n  return (\n    <>\n      {/* Link: literal and dynamic */}\n      <Link href=\"/about\" />\n      <Link href={`/blog/${slug}`} />\n      <Link href={('/blog/' + slug) as Route} />\n      {/* TypeScript error if href is not a valid route */}\n      <Link href=\"/aboot\" />\n \n      {/* Router: literal and dynamic strings are validated */}\n      <button onClick={() => router.push('/about')}>Push About</button>\n      <button onClick={() => router.replace(`/blog/${slug}`)}>\n        Replace Blog\n      </button>\n      <button onClick={() => router.prefetch('/contact')}>\n        Prefetch Contact\n      </button>\n \n      {/* For non-literal strings, cast to Route */}\n      <button onClick={() => router.push(('/blog/' + slug) as Route)}>\n        Push Non-literal Blog\n      </button>\n    </>\n  )\n}", "filename": ""}, {"language": "python", "code": "import { NextRequest, NextResponse } from 'next/server'\n \nexport function proxy(request: NextRequest) {\n  if (request.nextUrl.pathname === '/proxy-redirect') {\n    return NextResponse.redirect(new URL('/', request.url))\n  }\n \n  return NextResponse.next()\n}", "filename": ""}, {"language": "python", "code": "import type { Route } from 'next'\n \nexport default function Page() {\n  return <Link href={'/proxy-redirect' as Route}>Link Text</Link>\n}", "filename": ""}, {"language": "python", "code": "import type { Route } from 'next'\nimport Link from 'next/link'\n \nfunction Card<T extends string>({ href }: { href: Route<T> | URL }) {\n  return (\n    <Link href={href}>\n      <div>My Card</div>\n    </Link>\n  )\n}", "filename": ""}, {"language": "python", "code": "import type { Route } from 'next'\n \ntype NavItem<T extends string = string> = {\n  href: T\n  label: string\n}\n \nexport const navItems: NavItem<Route>[] = [\n  { href: '/', label: 'Home' },\n  { href: '/about', label: 'About' },\n  { href: '/blog', label: 'Blog' },\n]", "filename": ""}, {"language": "python", "code": "import Link from 'next/link'\nimport { navItems } from './nav-items'\n \nexport function Nav() {\n  return (\n    <nav>\n      {navItems.map((item) => (\n        <Link key={item.href} href={item.href}>\n          {item.label}\n        </Link>\n      ))}\n    </nav>\n  )\n}", "filename": ""}, {"language": "python", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  experimental: {\n    typedEnv: true,\n  },\n}\n \nexport default nextConfig", "filename": ""}, {"language": "python", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  typescript: {\n    tsconfigPath: 'tsconfig.build.json',\n  },\n}\n \nexport default nextConfig", "filename": ""}, {"language": "python", "code": "import type { NextConfig } from 'next'\n \nconst isProd = process.env.NODE_ENV === 'production'\n \nconst nextConfig: NextConfig = {\n  typescript: {\n    tsconfigPath: isProd ? 'tsconfig.build.json' : 'tsconfig.json',\n  },\n}\n \nexport default nextConfig", "filename": ""}, {"language": "text", "code": "{\n  \"extends\": \"./tsconfig.json\",\n  \"compilerOptions\": {\n    \"useUnknownInCatchVariables\": false\n  }\n}", "filename": ""}, {"language": "python", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  typescript: {\n    // !! WARN !!\n    // Dangerously allow production builds to successfully complete even if\n    // your project has type errors.\n    // !! WARN !!\n    ignoreBuildErrors: true,\n  },\n}\n \nexport default nextConfig", "filename": ""}, {"language": "carbon", "code": "{\n  \"compilerOptions\": {\n    \"skipLibCheck\": true\n    //...truncated...\n  },\n  \"include\": [\n    \"new-types.d.ts\",\n    \"next-env.d.ts\",\n    \".next/types/**/*.ts\",\n    \"**/*.ts\",\n    \"**/*.tsx\"\n  ],\n  \"exclude\": [\"node_modules\"]\n}", "filename": ""}], "chunk_position": 97, "heading_path": "Configuration: TypeScript | Next.js > Configuration: TypeScript | Next.js", "breadcrumbs": "Configuration: TypeScript | Next.js > Configuration: TypeScript | Next.js > Configuration: TypeScript | Next.js"}, {"id": "c70d7d034097f85e", "url": "https://nextjs.org/docs/app/api-reference/directives", "page_title": "Directives", "page_type": "reference", "page_summary": "This page provides an index of Next.js directives, including use cache, use client, and use server, with links to their detailed documentation.", "heading": "Directives", "content": "Page: Directives\nSection: Directives\n\nThe following directives are available:\n\n- [use cache](/docs/app/api-reference/directives/use-cache): Learn how to use the \"use cache\" directive to cache data in your Next.js application.\n- [use…", "code_blocks": [], "chunk_position": 98, "heading_path": "Directives > Directives", "breadcrumbs": "Directives > Directives > Directives"}, {"id": "fd5ece302194bcd9", "url": "https://nextjs.org/docs/app/api-reference/directives/use-cache", "page_title": "Directives: use cache | Next.js", "page_type": "reference", "page_summary": "Extraction fallback content.", "heading": "Directives: use cache | Next.js", "content": "Page: Directives: use cache | Next.js\nSection: Directives: use cache | Next.js\n\nThis page is also available as Markdown: request this page's URL with an `Accept: text/markdown` header.   For an index of  Next.js documentation , see  [/docs/llms.txt](/docs/llms.txt).Copy page\n\n##### use cache\n\nLast updated  July 22, 2026\n\nThe `use cache` directive allows you to mark a route, React component, or a function as cacheable. It can be used at the top of a file to indicate that all exports in the file should be cached, or inline at the top of a function or component to cache the return value. Functions and components that use `use cache` must be async.\n\n\n\n\n> **Good to know:** \n> \n> \n> \n> \n> \n> \n> - To use cookies or headers, read them outside cached scopes and pass values as arguments. This is the preferred pattern.\n> \n> - If the in-memory cache isn't sufficient for runtime data, [`'use cache: remote'`](/docs/app/api-reference/directives/use-cache-remote) allows platforms to provide a dedicated cache handler, though it requires a network roundtrip to check the cache and typically incurs platform fees.\n> \n> - For compliance requirements or when you can't refactor to pass runtime data as arguments to a `use cache` scope, see [`'use cache: private'`](/docs/app/api-reference/directives/use-cache-private).\n\n\n\n\n##### Usage\n\n\n\n\n`use cache` is a Cache Components feature. To enable it, add the [`cacheComponents`](/docs/app/api-reference/config/next-config-js/cacheComponents) option to your `next.config.ts` file:\n\n\nnext.config.tsTypeScriptJavaScriptTypeScript\n \n\n\nThen, add `use cache` at the file, component, or function level. All functions and components using `use cache` must be async. When used at file level, every exported function becomes a cached function and must also be async:\n\n\n\n\n\n##### How `use cache` works\n\n\n\n\n###### Cache keys\n\n\n\n\nA cache entry's key is generated using a serialized version of its inputs, which includes:\n\n\n\n\n\n\n- **Build ID**  - Unique per build, changing this invalidates all cache entries. If [`deploymentId`](/docs/app/api-reference/config/next-config-js/deploymentId) is configured, it overrides the build ID for cache key purposes.\n\n- **Function ID**  - A secure hash of the function's location and signature in the codebase\n\n- **Serializable arguments**  - Props (for components) or function arguments\n\n- **HMR refresh hash**  (development only) - Invalidates cache on hot module replacement\n\n\n\n\n\nWhen a cached function references variables from outer scopes, those variables are automatically captured and bound as arguments, making them part of the cache key.\n\n\nlib/data.ts\n\n\nIn the snippet above, `userId` is captured from the outer scope and `filter` is passed as an argument, so both become part of the `getData` function's cache key. This means different user and filter combinations will have separate cache entries.\n\n\n\n\n> **Good to know:**  When a cached function reads [root parameters](/docs/app/api-reference/functions/next-root-params), only the ones it actually reads become part of its cache key.\n\n\n\n\n##### Serialization\n\n\n\n\nArguments to cached functions and their return values must be serializable.\n\n\n\n\nFor a complete reference, see:\n\n\n\n\n\n\n- [Serializable arguments](https://react.dev/reference/rsc/use-server#serializable-parameters-and-return-values) - Uses  **React Server Components**  serialization\n\n- [Serializable return types](https://react.dev/reference/rsc/use-client#serializable-types) - Uses  **React Client Components**  serialization\n\n\n\n\n\n> **Good to know:**  Arguments and return values use different serialization systems. Server Component serialization (for arguments) is more restrictive than Client Component serialization (for return values). This means you can return JSX elements but cannot accept them as arguments unless using pass-through patterns.\n\n\n\n\n###### Supported types\n\n\n\n\n **Arguments:** \n\n\n\n\n\n\n- Primitives: `string`, `number`, `boolean`, `null`, `undefined`\n\n- Plain objects: `{ key: value }`\n\n- Arrays: `[1, 2, 3]`\n\n- Dates, Maps, Sets, TypedArrays, ArrayBuffers\n\n- React elements (as pass-through only)\n\n\n\n\n\n **Return values:** \n\n\n\n\n\n\n- Same as arguments, plus JSX elements\n\n\n\n\n\n###### Unsupported types\n\n\n\n\n\n\n- Class instances\n\n- Functions (except as pass-through)\n\n- Symbols, WeakMaps, WeakSets\n\n- URL instances\n\n\n\napp/components/user-card.tsx\n\n\n###### Pass-through (non-serializable arguments)\n\n\n\n\nYou can accept non-serializable values  **as long as you don't introspect them** . This enables composition patterns with `children` and Server Actions:\n\n\napp/components/cached-wrapper.tsx\n\n\nYou can also pass Server Actions through cached components:\n\n\napp/components/cached-form.tsx\n\n\n##### Constraints\n\n\n\n\nCached functions execute in an isolated environment. The following constraints ensure cache behavior remains predictable and secure.\n\n\n\n\n###### Request-time APIs\n\n\n\n\nCached functions and components  **cannot**  access runtime APIs like `cookies()`, `headers()`, or `searchParams`, and the restriction follows the call stack: a helper the cached function calls that reads one of these fails the same way, with the [`next-request-in-use-cache`](/docs/messages/next-request-in-use-cache) error. On a dynamically rendered route this surfaces when the route runs, so it can pass `next build` and fail under `next start`. Read these values outside the cached scope and pass them as arguments.\n\n\n\n\n###### Runtime caching considerations\n\n\n\n\nWhile `use cache` is designed primarily to include uncached data in the static shell, it can also cache data at runtime using in-memory LRU (Least Recently Used) storage.\n\n\n\n\nWith the default in-memory handler, runtime cache behavior depends on your hosting environment:\n\n\n\n\n\n\n\n| Environment | Runtime Caching Behavior |\n| --- | --- |\n\n\n\n\n| **Serverless** | Cache entries typically don't persist across requests (each request can be a different instance), or during revalidation. Build-time caching works normally. |\n| **Self-hosted** | Cache entries persist across requests. Control cache size with [`cacheMaxMemorySize`](/docs/app/api-reference/config/next-config-js/incrementalCacheHandlerPath). |\n\n\n\n\n\n\nFor example, in a serverless environment, a cached function shared by two pages executes on each static shell revalidation, whereas in self-hosted or environments with persistent memory, the cached output is reused if it's still fresh.\n\n\n\n\nIf the default in-memory cache isn't enough, consider  **[`use cache: remote`](/docs/app/api-reference/directives/use-cache-remote)**  which allows platforms to provide a dedicated cache handler (like Redis or KV database). This helps reduce hits against data sources not scaled to your total traffic, though it comes with costs (storage, network latency, platform fees).\n\n\n\n\nWith the default in-memory handler, serverless instances are ephemeral, so entries may not be reused between requests, unlike with `use cache: remote`. Neither caching directive carries over to a new deploy, because the [cache key](#cache-keys) includes the build (or `deploymentId`) ID.\n\n\n\nFor data that needs to persist across deploys, use [`unstable_cache`](/docs/app/api-reference/functions/unstable_cache) for non-`fetch` functions or the [`fetch`](/docs/app/api-reference/functions/fetch) cache.\n\n\n\n\nVery rarely, for compliance requirements or when you can't refactor your code to pass runtime data as arguments to a `use cache` scope, you might need [`use cache: private`](/docs/app/api-reference/directives/use-cache-private).\n\n\n\n\n###### Draft Mode\n\n\n\n\nWhen [Draft Mode](/docs/app/guides/draft-mode) is enabled, all cached functions and components re-execute on every request, and results are not saved to the cache. This ensures draft content is always fresh without requiring any changes to your caching code.\n\n\n\n\nYou can read `isEnabled` from [`draftMode()`](/docs/app/api-reference/functions/draft-mode) inside a `use cache` scope, however, other runtime APIs like `cookies()` and `headers()` are not allowed, even when Draft Mode is active. See [Passing runtime values to cached functions](/docs/app/getting-started/caching#passing-runtime-values-to-cached-functions) for the recommended pattern.\n\n\napp/components/content.tsx\n\n\nCalling `enable()` or `disable()` inside a caching directive scope will also throw an error. Draft Mode can only be toggled in [Route Handlers](/docs/app/api-reference/file-conventions/route) or [Server Actions](/docs/app/getting-started/mutating-data).\n\n\n\n\n###### React.cache isolation\n\n\n\n\n[`React.cache`](https://react.dev/reference/react/cache) operates in an isolated scope inside `use cache` boundaries. Values stored via `React.cache` outside a `use cache` function are not visible inside it.\n\n\n\n\nThis means you cannot use `React.cache` to pass data into a `use cache` scope:\n\n\n\n\n\nThis isolation ensures cached functions have predictable, self-contained behavior. To pass data into a `use cache` scope, use function arguments instead.\n\n\n\n\n##### `use cache` at runtime\n\n\n\n\nOn the  **server** , cache entries are stored in-memory and respect the `revalidate` and `expire` times from your `cacheLife` configuration. You can customize the cache storage by configuring [`cacheHandlers`](/docs/app/api-reference/config/next-config-js/cacheHandlers) in your `next.config.js` file.\n\n\n\n\nOn the  **client** , content from the server cache is stored in the browser's memory for the duration defined by the `stale` time. The client router enforces a  **minimum 30-second stale time** , regardless of configuration.\n\n\n\n\nThe `x-nextjs-stale-time` response header communicates cache lifetime from server to client, ensuring coordinated behavior.\n\n\n\n\n##### Revalidation\n\n\n\n\nCached functions revalidate based on the `revalidate` and `expire` times in their `cacheLife` profile, or on-demand through tags. These two approaches are not mutually exclusive and are often paired:\n\n\n\n\n\n\n- **[Time-based](#time-based-revalidation)** : refresh automatically after a set duration with [`cacheLife`](/docs/app/api-reference/functions/cacheLife).\n\n- **[On-demand](#on-demand-revalidation)** : invalidate after a mutation with [`cacheTag`](/docs/app/api-reference/functions/cacheTag) and [`revalidateTag`](/docs/app/api-reference/functions/revalidateTag) or [`updateTag`](/docs/app/api-reference/functions/updateTag).\n\n\n\n\n\nFor example, a blog post that changes only when its author edits it can use a long `cacheLife` like `max` with a `cacheTag`, then invalidate on demand when the post is saved. A list of recent posts that updates throughout the day can use a shorter profile like `hours` to refresh on its own, without manual invalidation.\n\n\n\n\n###### Time-based revalidation\n\n\n\n\nSet an explicit cache lifetime with [`cacheLife`](/docs/app/api-reference/functions/cacheLife) in every `use cache` scope. It makes the cache behavior clear at the call site, instead of depending on the `default` profile or surrounding caches.\n\n\nlib/data.ts\n\n\nIf you omit `cacheLife`, the `default` profile applies and the lifetime is no longer explicit at the call site:\n\n\n\n\n\n\n- **stale** : 5 minutes (client-side)\n\n- **revalidate** : 15 minutes (server-side)\n\n- **expire** : never expires by time\n\n\n\nlib/data.ts\n\n\nNesting a short-lived use cache inside one without an explicit [cacheLife](/docs/app/api-reference/functions/cacheLife) fails the build during prerendering. See [Nested short-lived caches](/docs/app/api-reference/functions/cacheLife#nested-short-lived-caches) for the rule and fix.\n\n\n\n\n###### On-demand revalidation\n\n\n\n\nUse [`cacheTag`](/docs/app/api-reference/functions/cacheTag), [`updateTag`](/docs/app/api-reference/functions/updateTag), or [`revalidateTag`](/docs/app/api-reference/functions/revalidateTag) for on-demand cache invalidation:\n\n\nlib/data.ts\napp/actions.ts\n\n\nBoth `cacheLife` and `cacheTag` integrate across client and server caching layers, meaning you configure your caching semantics in one place and they apply everywhere.\n\n\n\n\n##### Examples\n\n\n\n\n###### Caching an entire route with `use cache`\n\n\n\n\nTo prerender an entire route, add `use cache` to the top of  **both**  the `layout` and `page` files. Each of these segments are treated as separate entry points in your application, and will be cached independently.\n\n\napp/layout.tsxTypeScriptJavaScriptTypeScript\n \n\n\nAny components imported and nested in `page` file are part of the cache output associated with the `page`.\n\n\napp/page.tsxTypeScriptJavaScriptTypeScript\n \n\n\n> **Good to know** :\n> \n> \n> \n> \n> \n> \n> - If `use cache` is added only to the `layout` or the `page`, only that route segment and any components imported into it will be cached.\n\n\n\n\n###### Caching a component's output with `use cache`\n\n\n\n\nYou can use `use cache` at the component level to cache any fetches or computations performed within that component. The cache entry will be reused as long as the serialized props produce the same value in each instance.\n\n\napp/components/bookings.tsxTypeScriptJavaScriptTypeScript\n \n\n\n###### Caching function output with `use cache`\n\n\n\n\nSince you can add `use cache` to any asynchronous function, you aren't limited to caching components or routes only. You might want to cache a network request, a database query, or a slow computation.\n\n\napp/actions.tsTypeScriptJavaScriptTypeScript\n \n\n\n> **Good to know:**  When a cached directive (`use cache`, [`use cache: private`](/docs/app/api-reference/directives/use-cache-private), or [`use cache: remote`](/docs/app/api-reference/directives/use-cache-remote)) is at the top of a file, you can import its exported functions into a Client Component and call them directly; they run on the server and return the result, similar to a [Server Function](/docs/app/glossary#server-function). Prefer calling cached functions on the server and passing results down as props.\n\n\n\n\n###### Interleaving\n\n\n\n\nIn React, composition with `children` or slots is a well-known pattern for building flexible components. When using `use cache`, you can continue to compose your UI in this way. Anything included as `children`, or other compositional slots, in the returned JSX will be passed through the cached component without affecting its cache entry.\n\n\n\n\nAs long as you don't directly reference any of the JSX slots inside the body of the cacheable function itself, their presence in the returned output won't affect the cache entry.\n\n\napp/page.tsxTypeScriptJavaScriptTypeScript\n \n\n\nYou can also pass Server Actions through cached components to Client Components without invoking them inside the cacheable function.\n\n\napp/page.tsxTypeScriptJavaScriptTypeScript\n \napp/ClientComponent.tsxTypeScriptJavaScriptTypeScript\n \n\n\n##### Troubleshooting\n\n\n\n\n###### Debugging cache behavior\n\n\n\n\n###### Verbose logging\n\n\n\n\nSet `NEXT_PRIVATE_DEBUG_CACHE=1` for verbose cache logging:\n\n\n\n\n\n> **Good to know:**  This environment variable also logs ISR and other caching mechanisms. See [Verifying correct production behavior](/docs/app/guides/incremental-static-regeneration#verifying-correct-production-behavior) for more details.\n\n\n\n\n###### Console log replays\n\n\n\n\nIn development, console logs from cached functions appear with a `Cache` prefix.\n\n\n\n\n###### Build Hangs (Cache Timeout)\n\n\n\n\nIf your build hangs, you're accessing Promises that resolve to uncached or runtime data, created outside a `use cache` boundary. The cached function waits for data that can't resolve during the build, causing a timeout after 50 seconds.\n\n\n\n\nWhen the build timeouts you'll see this error message:\n\n\n\n\n> Error: Filling a cache during prerender timed out, likely because request-specific arguments such as params, searchParams, cookies() or uncached data were used inside \"use cache\".\n\n\n\n\nCommon ways this happens: passing such Promises as props, accessing them via closure, or retrieving them from shared storage (Maps).\n\n\n\n\n> **Good to know:**  Directly calling `cookies()` or `headers()` inside `use cache` fails immediately with a [different error](/docs/messages/next-request-in-use-cache), not a timeout.\n\n\n\n\n **Passing runtime data Promises as props:** \n\n\napp/page.tsx\n\n\nAwait the `cookies` store in the `Dynamic` component, and pass a cookie value to the `Cached` component.\n\n\n\n\n **Shared deduplication storage:** \n\n\napp/page.tsx\n\n\nUse Next.js's built-in `fetch()` deduplication or use separate Maps for cached and uncached contexts.\n\n\n\n\n##### Platform Support\n\n\n\n\n\n\n\n| Deployment Option | Supported |\n| --- | --- |\n\n\n\n\n| [Node.js server](/docs/app/getting-started/deploying#nodejs-server) | Yes |\n| [Docker container](/docs/app/getting-started/deploying#docker) | Yes |\n| [Static export](/docs/app/getting-started/deploying#static-export) | No |\n| [Adapters](/docs/app/getting-started/deploying#adapters) | Platform-specific |\n\n\n\n\n\n\nLearn how to [configure caching](/docs/app/guides/self-hosting#caching-and-isr) when self-hosting Next.js.\n\n\n\n\n##### Version History\n\n\n\n\n\n\n\n| Version | Changes |\n| --- | --- |\n\n\n\n\n| `v16.0.0` | `\"use cache\"` is enabled with the Cache Components feature. |\n| `v15.0.0` | `\"use cache\"` is introduced as an experimental feature. |\n\n\n\n\n\n##### Related\n\nView related API references.[### use cache: private\n\nLearn how to use the \"use cache: private\" directive to cache functions that access runtime request APIs.](/docs/app/api-reference/directives/use-cache-private)[### cacheComponents\n\nLearn how to enable the cacheComponents flag in Next.js.](/docs/app/api-reference/config/next-config-js/cacheComponents)[### cacheLife\n\nLearn how to set up cacheLife configurations in Next.js.](/docs/app/api-reference/config/next-config-js/cacheLife)[### cacheHandlers\n\nConfigure custom cache handlers for use cache directives in Next.js.](/docs/app/api-reference/config/next-config-js/cacheHandlers)[### cacheTag\n\nLearn how to use the cacheTag function to manage cache invalidation in your Next.js application.](/docs/app/api-reference/functions/cacheTag)[### cacheLife\n\nLearn how to use the cacheLife function to set the cache expiration time for a cached function or component.](/docs/app/api-reference/functions/cacheLife)[### revalidateTag\n\nAPI Reference for the revalidateTag function.](/docs/app/api-reference/functions/revalidateTag)\n\nWas this helpful?\n\nsupported.Send", "code_blocks": [{"language": "python", "code": "import type { NextConfig } from 'next'\n \nconst nextConfig: NextConfig = {\n  cacheComponents: true,\n}\n \nexport default nextConfig", "filename": ""}, {"language": "gdscript", "code": "// File level\n'use cache'\n \nexport default async function Page() {\n  // ...\n}\n \n// Component level\nexport async function MyComponent() {\n  'use cache'\n  return <></>\n}\n \n// Function level\nexport async function getData() {\n  'use cache'\n  const data = await fetch('/api/data')\n  return data\n}", "filename": ""}, {"language": "gdscript", "code": "async function Component({ userId }: { userId: string }) {\n  const getData = async (filter: string) => {\n    'use cache'\n    // Cache key includes both userId (from closure) and filter (argument)\n    return fetch(`/api/users/${userId}/data?filter=${filter}`)\n  }\n \n  return getData('active')\n}", "filename": ""}, {"language": "xml", "code": "// Valid - primitives and plain objects\nasync function UserCard({\n  id,\n  config,\n}: {\n  id: string\n  config: { theme: string }\n}) {\n  'use cache'\n  return <div>{id}</div>\n}\n \n// Invalid - class instance\nasync function UserProfile({ user }: { user: UserClass }) {\n  'use cache'\n  // Error: Cannot serialize class instance\n  return <div>{user.name}</div>\n}", "filename": ""}, {"language": "xml", "code": "async function CachedWrapper({ children }: { children: ReactNode }) {\n  'use cache'\n  // Don't read or modify children - just pass it through\n  return (\n    <div className=\"wrapper\">\n      <header>Cached Header</header>\n      {children}\n    </div>\n  )\n}\n \n// Usage: children can be dynamic\nexport default function Page() {\n  return (\n    <CachedWrapper>\n      <DynamicComponent /> {/* Not cached, passed through */}\n    </CachedWrapper>\n  )\n}", "filename": ""}, {"language": "xml", "code": "async function CachedForm({ action }: { action: () => Promise<void> }) {\n  'use cache'\n  // Don't call action here - just pass it through\n  return <form action={action}>{/* ... */}</form>\n}", "filename": ""}, {"language": "python", "code": "import { draftMode } from 'next/headers'\n \nasync function Content() {\n  'use cache'\n \n  const { isEnabled } = await draftMode()\n  const url = isEnabled\n    ? 'https://draft.example.com/content'\n    : 'https://production.example.com/content'\n \n  const data = await fetch(url)\n  return <article>{/* ... */}</article>\n}", "filename": ""}, {"language": "python", "code": "import { cache } from 'react'\n \nconst store = cache(() => ({ current: null as string | null }))\n \nfunction Parent() {\n  const shared = store()\n  shared.current = 'value from parent'\n  return <Child />\n}\n \nasync function Child() {\n  'use cache'\n  const shared = store()\n  // shared.current is null, not 'value from parent'\n  // use cache has its own isolated React.cache scope\n  return <div>{shared.current}</div>\n}", "filename": ""}, {"language": "python", "code": "import { cacheLife } from 'next/cache'\n \nasync function getData() {\n  'use cache'\n  cacheLife('hours') // Use built-in 'hours' profile\n  return fetch('/api/data')\n}", "filename": ""}, {"language": "teratermmacro", "code": "async function getData() {\n  'use cache'\n  // Implicitly uses the 'default' profile\n  return fetch('/api/data')\n}", "filename": ""}, {"language": "python", "code": "import { cacheTag } from 'next/cache'\n \nasync function getProducts() {\n  'use cache'\n  cacheTag('products')\n  return fetch('/api/products')\n}", "filename": ""}, {"language": "python", "code": "'use server'\n \nimport { updateTag } from 'next/cache'\n \nexport async function updateProduct() {\n  await db.products.update(...)\n  updateTag('products') // Invalidates all 'products' caches\n}", "filename": ""}, {"language": "xml", "code": "'use cache'\n \nexport default async function Layout({ children }: { children: ReactNode }) {\n  return <div>{children}</div>\n}", "filename": ""}, {"language": "xml", "code": "'use cache'\n \nasync function Users() {\n  const users = await fetch('/api/users')\n  // loop through users\n}\n \nexport default async function Page() {\n  return (\n    <main>\n      <Users />\n    </main>\n  )\n}", "filename": ""}, {"language": "gdscript", "code": "export async function Bookings({ type = 'haircut' }: BookingsProps) {\n  'use cache'\n  async function getBookingsData() {\n    const data = await fetch(`/api/bookings?type=${encodeURIComponent(type)}`)\n    return data\n  }\n  return //...\n}\n \ninterface BookingsProps {\n  type: string\n}", "filename": ""}, {"language": "gdscript", "code": "export async function getData() {\n  'use cache'\n \n  const data = await fetch('/api/data')\n  return data\n}", "filename": ""}, {"language": "xml", "code": "export default async function Page() {\n  const uncachedData = await getData()\n  return (\n    // Pass compositional slots as props, e.g. header and children\n    <CacheComponent header={<h1>Home</h1>}>\n      {/* DynamicComponent is provided as the children slot */}\n      <DynamicComponent data={uncachedData} />\n    </CacheComponent>\n  )\n}\n \nasync function CacheComponent({\n  header, // header: a compositional slot, injected as a prop\n  children, // children: another slot for nested composition\n}: {\n  header: ReactNode\n  children: ReactNode\n}) {\n  'use cache'\n  const cachedData = await fetch('/api/cached-data')\n  return (\n    <div>\n      {header}\n      <PrerenderedComponent data={cachedData} />\n      {children}\n    </div>\n  )\n}", "filename": ""}, {"language": "python", "code": "import ClientComponent from './ClientComponent'\n \nexport default async function Page() {\n  const performUpdate = async () => {\n    'use server'\n    // Perform some server-side update\n    await db.update(...)\n  }\n \n  return <CachedComponent performUpdate={performUpdate} />\n}\n \nasync function CachedComponent({\n  performUpdate,\n}: {\n  performUpdate: () => Promise<void>\n}) {\n  'use cache'\n  // Do not call performUpdate here\n  return <ClientComponent action={performUpdate} />\n}", "filename": ""}, {"language": "xml", "code": "'use client'\n \nexport default function ClientComponent({\n  action,\n}: {\n  action: () => Promise<void>\n}) {\n  return <button onClick={action}>Update</button>\n}", "filename": ""}, {"language": "scdoc", "code": "NEXT_PRIVATE_DEBUG_CACHE=1 npm run dev\n# or for production\nNEXT_PRIVATE_DEBUG_CACHE=1 npm run start", "filename": ""}, {"language": "python", "code": "import { cookies } from 'next/headers'\nimport { Suspense } from 'react'\n \nexport default function Page() {\n  return (\n    <Suspense fallback={<div>Loading...</div>}>\n      <Dynamic />\n    </Suspense>\n  )\n}\n \nasync function Dynamic() {\n  const cookieStore = cookies()\n  return <Cached promise={cookieStore} /> // Build hangs\n}\n \nasync function Cached({ promise }: { promise: Promise<unknown> }) {\n  'use cache'\n  const data = await promise // Waits for runtime data during build\n  return <p>..</p>\n}", "filename": ""}, {"language": "python", "code": "// Problem: Map stores dynamic Promises, accessed by cached code\nimport { Suspense } from 'react'\n \nconst cache = new Map<string, Promise<string>>()\n \nexport default function Page() {\n  return (\n    <>\n      <Suspense fallback={<div>Loading...</div>}>\n        <Dynamic id=\"data\" />\n      </Suspense>\n      <Cached id=\"data\" />\n    </>\n  )\n}\n \nasync function Dynamic({ id }: { id: string }) {\n  // Stores dynamic Promise in shared Map\n  cache.set(\n    id,\n    fetch(`https://api.example.com/${id}`).then((r) => r.text())\n  )\n  return <p>Dynamic</p>\n}\n \nasync function Cached({ id }: { id: string }) {\n  'use cache'\n  return <p>{await cache.get(id)}</p> // Build hangs - retrieves dynamic Promise\n}", "filename": ""}], "chunk_position": 99, "heading_path": "Directives: use cache | Next.js > Directives: use cache | Next.js", "breadcrumbs": "Directives: use cache | Next.js > Directives: use cache | Next.js > Directives: use cache | Next.js"}, {"id": "5acbfda78ad69a4b", "url": "https://nextjs.org/docs/app/api-reference/directives/use-cache-private", "page_title": "use cache: private", "page_type": "api", "page_summary": "This page documents the 'use cache: private' directive in Next.js, which allows functions to access runtime request APIs within a cached scope while caching results only in the browser's memory and…", "heading": "Overview", "content": "Page: use cache: private\nSection: Overview\n\nThe `'use cache: private'` directive allows functions to access runtime request APIs like `cookies()`, `headers()`, and `searchParams` within a cached scope. However, results are **never stored on…", "code_blocks": [], "chunk_position": 100, "heading_path": "Overview > Overview", "breadcrumbs": "use cache: private > Overview > Overview"}, {"id": "2e8d1023b2debe8d", "url": "https://nextjs.org/docs/app/api-reference/directives/use-cache-private", "page_title": "use cache: private", "page_type": "api", "page_summary": "This page documents the 'use cache: private' directive in Next.js, which allows functions to access runtime request APIs within a cached scope while caching results only in the browser's memory and…", "heading": "Usage", "content": "Page: use cache: private\nSection: Usage\n\nTo use `'use cache: private'`, enable the [`cacheComponents`](/docs/app/api-reference/config/next-config-js/cacheComponents) flag in your `next.config.ts` file:\n\nThen add `'use cache: private'` to…", "code_blocks": [{"language": "ts", "code": "import type { NextConfig } from 'next'\n\nconst nextConfig: NextConfig = {\n  cacheComponents: true,\n}\n\nexport default nextConfig", "filename": "next.config.ts"}], "chunk_position": 100, "heading_path": "Usage > Usage", "breadcrumbs": "use cache: private > Usage > Usage"}, {"id": "2f8198b1f50d0eec", "url": "https://nextjs.org/docs/app/api-reference/directives/use-cache-private", "page_title": "use cache: private", "page_type": "api", "page_summary": "This page documents the 'use cache: private' directive in Next.js, which allows functions to access runtime request APIs within a cached scope while caching results only in the browser's memory and…", "heading": "Basic example", "content": "Page: use cache: private\nSection: Basic example\n\nIn this example, we demonstrate that you can access cookies within a `'use cache: private'` scope:\n\n> **Good to know** : The `stale` time must be at least 30 seconds for per-link prefetching to work,…", "code_blocks": [{"language": "tsx", "code": "import { Suspense } from 'react'\nimport { cookies } from 'next/headers'\nimport { cacheLife, cacheTag } from 'next/cache'\n\nexport async function generateStaticParams() {\n  return [{ id: '1'…", "filename": "app/product/[id]/page.tsx"}], "chunk_position": 100, "heading_path": "Basic example > Basic example", "breadcrumbs": "use cache: private > Basic example > Basic example"}, {"id": "2f1ed239fb0d6f3e", "url": "https://nextjs.org/docs/app/api-reference/directives/use-cache-private", "page_title": "use cache: private", "page_type": "api", "page_summary": "This page documents the 'use cache: private' directive in Next.js, which allows functions to access runtime request APIs within a cached scope while caching results only in the browser's memory and…", "heading": "Request APIs allowed in private caches", "content": "Page: use cache: private\nSection: Request APIs allowed in private caches\n\nThe following request-specific APIs can be used inside `'use cache: private'` functions:\n\n| API | Allowed in `use cache` | Allowed in `'use cache: private'` |\n| --- | --- | --- |\n| `cookies()` | No |…", "code_blocks": [], "chunk_position": 100, "heading_path": "Request APIs allowed in private caches > Request APIs allowed in private caches", "breadcrumbs": "use cache: private > Request APIs allowed in private caches > Request APIs allowed in private caches"}, {"id": "4bde6f1fb6793a67", "url": "https://nextjs.org/docs/app/api-reference/directives/use-cache-private", "page_title": "use cache: private", "page_type": "api", "page_summary": "This page documents the 'use cache: private' directive in Next.js, which allows functions to access runtime request APIs within a cached scope while caching results only in the browser's memory and…", "heading": "Version History", "content": "Page: use cache: private\nSection: Version History\n\n| Version | Changes |\n| --- | --- |\n| `v16.0.0` | `\"use cache: private\"` is enabled with the Cache Components feature. |", "code_blocks": [], "chunk_position": 100, "heading_path": "Version History > Version History", "breadcrumbs": "use cache: private > Version History > Version History"}, {"id": "ecc794ba02fd7db0", "url": "https://nextjs.org/docs/app/api-reference/directives/use-cache-private", "page_title": "use cache: private", "page_type": "api", "page_summary": "This page documents the 'use cache: private' directive in Next.js, which allows functions to access runtime request APIs within a cached scope while caching results only in the browser's memory and…", "heading": "Related", "content": "Page: use cache: private\nSection: Related\n\nView related API references.\n\n- [### use cache - Learn how to use the \"use cache\" directive to cache data in your Next.js application.](/docs/app/api-reference/directives/use-cache)\n- [###…", "code_blocks": [], "chunk_position": 100, "heading_path": "Related > Related", "breadcrumbs": "use cache: private > Related > Related"}]