# @next/bundle-analyzer

> Use `webpack-bundle-analyzer` in your Next.js project

Latest version **16.4.0** (published 2026-10-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @next/bundle-analyzer
pnpm add @next/bundle-analyzer
yarn add @next/bundle-analyzer
bun add @next/bundle-analyzer
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 16.4.0 |
| Published | 2026-10-06 |
| First published | 2019-02-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 143196 |
| Maintainers | vercel-release-bot, matt.straka |

## Links

- npm: https://www.npmjs.com/package/@next/bundle-analyzer
- Repository: https://github.com/vercel/next.js
- Homepage: https://github.com/vercel/next.js#readme
- Issues: https://github.com/vercel/next.js/issues
- npm.io page: https://npm.io/package/@next/bundle-analyzer

## Dependencies (1)

- [webpack-bundle-analyzer](https://npm.io/package/webpack-bundle-analyzer.md) 4.10.1

## Recent versions

- 16.4.0 (latest) — 2026-10-06
- 16.5.0-canary.8 (canary) — 2026-10-10
- 15.5.27 (backport) — 2026-09-30
- 16.3.0-preview.10 (preview) — 2026-07-28
- 15.0.8 (next-15-0-0) — 2026-01-26
- 15.1.12 (next-15-0) — 2026-01-26
- 15.2.9 (next-15-2) — 2026-01-26
- 15.3.9 (next-15-3) — 2026-01-26
- 14.2.35 (next-14) — 2025-12-11
- 16.0.0-beta.0 (beta) — 2025-10-10
- 12.3.7 (next-12-3-2) — 2025-03-28
- 13.5.11 (next-13) — 2025-03-27
- 15.0.0-rc.1 (rc) — 2024-10-15
- 14.1.1 (next-14-1) — 2024-02-29
- 12.2.6 (next-12-2-6) — 2022-09-29
- … 3616 more at https://npm.io/package/@next/bundle-analyzer/versions

## README

# Next.js + Webpack Bundle Analyzer

Use `webpack-bundle-analyzer` in your Next.js project

## Installation

```
npm install @next/bundle-analyzer
```

or

```
yarn add @next/bundle-analyzer
```

Note: if installing as a `devDependency` make sure to wrap the require in a `process.env` check as `next.config.js` is loaded during `next start` as well.

### Usage with environment variables

Create a next.config.js (and make sure you have next-bundle-analyzer set up)

```js
const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true',
})
module.exports = withBundleAnalyzer({})
```

Or configuration as a function:

```js
module.exports = (phase, defaultConfig) => {
  return withBundleAnalyzer(defaultConfig)
}
```

Then you can run the command below:

```bash
# Analyze is done on build when env var is set
ANALYZE=true yarn build
```

When enabled three HTML files (client.html, edge.html and nodejs.html) will be outputted to `<distDir>/analyze/`. One will be for the nodejs server bundle, one for the edge server bundle, and one for the browser bundle.

#### Options

To disable automatically opening the report in your default browser, set `openAnalyzer` to false:

```js
const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true',
  openAnalyzer: false,
})
module.exports = withBundleAnalyzer({})
```

### Usage with next-compose-plugins

From version 2.0.0 of next-compose-plugins you need to call bundle-analyzer in this way to work

```js
const withPlugins = require('next-compose-plugins')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true',
})

module.exports = withPlugins([
  [withBundleAnalyzer],
  // your other plugins here
])
```

---
_Source: https://npm.io/package/@next/bundle-analyzer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
