nuxt analyze

Analyze the production bundle or your Nuxt application.
Terminal
npx nuxt analyze [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv=<path>...] [-e, --extends=<layer-name>...] [--name=<name>] [--serve] [--prerender] [--json]

The analyze command builds Nuxt and analyzes the production bundle (experimental). The results are served on a local server when the build finishes, unless you pass --no-serve or CI is set in the environment.

The server links to each report: the client bundle and the Nitro server bundle. When only one report exists, the server shows it directly. The server uses the port in PORT, or port 3000. If that port is in use, it picks a free port between 3000 and 3100.

Each run is written to its own directory inside analyzeDir, named after --name (default when omitted), so you can keep several runs side by side, for example --name=before and --name=after. Running again with the same name replaces that run only. Characters other than letters, digits, _ and - are replaced with _ in the directory name, so --name=after/fix and --name=after_fix share the same directory. If you set build.analyze.filename, the client report is written to that path instead. With Nuxt 3 and 4, nitro.analyze.filename does the same for the Nitro report.

Pass --json to write the reports as JSON instead of HTML: client.json and nitro.json, in the raw-data format of rollup-plugin-visualizer. They include each module's size, the chunk it ends up in, and its static and dynamic imports. This makes them easy to process with scripts or AI agents. Nothing is served in this mode. A custom report filename ending in .html is written with a .json extension instead. With the webpack and rspack builders, client.json is the webpack stats file rather than raw-data.

With Nuxt 5, the Nitro report needs rollup-plugin-visualizer in your project. If it's missing, the Nitro report is skipped. With the Vite builder, Nuxt also offers to install it as a dev dependency.

Routes are not prerendered while analyzing, since prerendering runs the built app and its output is not what is being measured. Pass --prerender if your analysis needs it.

Arguments

ArgumentDescription
ROOTDIRThe root directory of your Nuxt project (default: .)

Options

OptionDefaultDescription
--cwd=<directory>Specify the root directory of your Nuxt project
--logLevel=<silent|info|verbose>Specify build-time log level
--dotenv=<path>...Path to .env file to load, relative to the root directory. Can be repeated, with later files taking precedence.
-e, --extends=<layer-name>...Extend from a Nuxt layer
--name=<name>defaultName of the analysis
--servetrueServe the analysis results
--no-serveSkip serving the analysis results
--prerenderfalsePrerender routes while analyzing
--jsonfalseWrite the client and server bundle analysis as JSON instead of HTML (implies --no-serve)
This command sets process.env.NODE_ENV to production.

Was this helpful?