Library: /vercel/next.js ### Next.js Overview and Core Concepts Source: https://github.com/vercel/next.js/blob/canary/docs/index.mdx The main documentation index page describing what Next.js is, its two routers (App Router and Pages Router), and key features like Server Components, Suspense, and Server Functions. It explains that Next.js is a React framework for building full-stack web applications that automatically configures lower-level tools like bundlers and compilers. ```markdown ## What is Next.js? Next.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 configures lower-level tools like bundlers and compilers. You can instead focus on building your product and shipping quickly. Whether you're an individual developer or part of a larger team, Next.js can help you build interactive, dynamic, and fast React applications. ``` ### Next.js Docs > What is Next.js? Source: https://github.com/vercel/next.js/blob/canary/docs/index.mdx Next.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 configures lower-level tools like bundlers and compilers. You can instead focus on building your product and shipping quickly. Whether you're an individual developer or part of a larger team, Next.js can help you build interactive, dynamic, and fast React applications. --- Library: /websites/nextjs_app_api-reference_config_next-config-js ### next.config.js Source: https://nextjs.org/docs/app/api-reference/config/next-config-js The next.config.js file is a standard Node.js module located in the root of your project directory. It is utilized by the Next.js server and build phases and is not included in the browser build. --- Library: /vercel/next.js ### Next.js Docs > Join our Community Source: https://github.com/vercel/next.js/blob/canary/docs/index.mdx If you have questions about anything related to Next.js, you're always welcome to ask our community on [GitHub Discussions](https://github.com/vercel/next.js/discussions), [Discord](https://discord.com/invite/bUG2bvbtHy), [X (Twitter)](https://x.com/nextjs), and [Reddit](https://www.reddit.com/r/nextjs). ### Next.js Docs > App Router and Pages Router Source: https://github.com/vercel/next.js/blob/canary/docs/index.mdx Next.js has two different routers: - **App Router**: The newer router that supports new React features like Server Components. - **Pages Router**: The original router, still supported and being improved. At the top of the sidebar, you'll notice a dropdown menu that allows you to switch between the [App Router](/docs/app) and the [Pages Router](/docs/pages) docs. --- Library: /websites/nextjs_app_api-reference_config_next-config-js ### next.config.js > ECMAScript Modules Source: https://nextjs.org/docs/app/api-reference/config/next-config-js You can use next.config.mjs if you require ECMAScript modules. Note that .cjs and .cts extensions are currently not supported for configuration files. ### Next.js Configuration Reference Source: https://nextjs.org/docs/app/api-reference/config/next-config-js Next.js provides extensive configuration options to manage build behavior, including support for transpiling monorepo packages, customizing webpack or Turbopack settings, and enabling experimental features like Lightning CSS or the React Compiler. Developers can control static generation, client-side caching, and TypeScript integration to optimize production builds and development workflows. ### Configuration Options Source: https://nextjs.org/docs/app/api-reference/config/next-config-js Next.js offers various configuration options to manage application behavior, including environment variables, custom build directories, CDN asset prefixes, and base paths for sub-domain deployments. Advanced features include cache management, CSS chunking control, and deployment identifiers for version skew protection. Additionally, developers can configure development indicators and compression settings to optimize the development and production experience. ### next.config.js > Build Configuration Source: https://nextjs.org/docs/app/api-reference/config/next-config-js Next.js provides extensive configuration options to manage build processes, such as customizing export paths, generating unique build IDs, and enabling production browser source maps. Developers can also control output tracing and incorporate custom salts into content-addressed filenames. ### Next.js Configuration Reference > Advanced Configuration Source: https://nextjs.org/docs/app/api-reference/config/next-config-js Advanced features such as typed routes, web vitals attribution, and tainting objects provide tools for improving application reliability and performance monitoring. Additionally, developers can configure asset handling, trailing slash behavior, and external URL imports to suit specific deployment requirements. ### Unit Testing (experimental) Source: https://nextjs.org/docs/app/api-reference/config/next-config-js Starting in Next.js 15.1, the next/experimental/testing/server package provides utilities for unit testing configuration files. The unstable_getResponseFromNextConfig function allows testing of headers, redirects, and rewrites by simulating request information. Be aware that these tests only consider configuration fields and do not account for proxy or filesystem routes, meaning production behavior may differ. ### next.config.js > Infrastructure and Logging Source: https://nextjs.org/docs/app/api-reference/config/next-config-js Application infrastructure can be customized through external cache handlers for services like Redis or Memcached, logging configurations for development environments, and instrumentation injection. Security and metadata settings allow for blocking specific bots and managing the x-powered-by header. ### TypeScript Source: https://nextjs.org/docs/app/api-reference/config/next-config-js Projects can use next.config.ts to define configuration using TypeScript. While configuration options are available, none are strictly required; developers should search for specific features they need to modify. Note that the configuration file is not parsed by Webpack or Babel, so developers should avoid using JavaScript features not supported by their target Node.js version. ### Next.js Configuration Reference > Turbopack Source: https://nextjs.org/docs/app/api-reference/config/next-config-js Turbopack configuration allows for fine-grained control over build performance and behavior, including chunking strategies, file system caching, and memory eviction policies. It also supports specific overrides for PostCSS resolution and the ability to suppress CLI warnings or errors through ignore rules. ### next.config.js > Performance and Rendering Source: https://nextjs.org/docs/app/api-reference/config/next-config-js Performance and rendering features include enabling the React Compiler for automatic rendering optimization, configuring React Strict Mode, and setting limits on header lengths. Developers can also manage image loading, inline CSS support, and MDX compilation using the Rust compiler. ### next.config.js > Configuration as a Function Source: https://nextjs.org/docs/app/api-reference/config/next-config-js Configuration can be defined as a function or an async function, which allows for dynamic settings based on the current phase. The phase parameter represents the context in which the configuration is loaded and can be imported from next/constants to apply conditional settings. ### next.config.js > Routing and Network Source: https://nextjs.org/docs/app/api-reference/config/next-config-js Routing and network behavior can be fine-tuned using redirects, rewrites, and custom HTTP headers. Additionally, developers can configure proxy request body sizes, manage HTTP Keep-Alive settings, and control prefetching behavior to optimize how static route parts are loaded.