documents/dev/nextjs.md

CatchRoutes

experimental-analyze

Added in Next.js v16.1.0. Analyzes your application's bundle output using Turbopack. Helps understand the size and composition of bundles (JavaScript, CSS, other assets). Does not produce a build artifact.

npx next experimental-analyze

By default, starts a local server (port 4000) after analysis so you can explore bundle composition in the browser:

  • Filter bundles by route
  • Switch between client and server views
  • View the full import chain showing why a module is included
  • Trace imports across server-to-client component boundaries and dynamic imports

Options

Option Description
-h, --help Show all available options
[directory] Directory to analyze (default: current dir)
--no-mangling Disable mangling (may affect perf, debugging only)
--profile Enable production profiling for React
-o, --output Write analysis to .next/diagnostics/analyze without starting server
--port <port> Port for the analyzer server (default: 4000, env: PORT)

Example — save analysis to disk

npx next experimental-analyze --output
cp -r .next/diagnostics/analyze ./analyze-before-refactor