# Is web-vitals ESM-only? Can you require() it?

> web-vitals@6.2.1 ships CommonJS and ESM builds. Dual package — require() works on every Node.js version we test; import works too.

Easily measure performance metrics in JavaScript

Last verified Sep 9, 2026 against web-vitals@6.2.1.

web-vitals publishes both a CommonJS entry and a native ESM entry (ESM added in 0.1.0). require("web-vitals") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "web-vitals" works alongside it.

## What to do

1. Nothing to change. require("web-vitals") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as webVitals from "web-vitals" works alongside it; use named imports for what the ESM entry exports.
2. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 6.2.1 (Aug 26, 2026)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 6.2.1
- Native ESM since: 0.1.0
- TypeScript types: bundled
- Node engines: not declared
- Weekly downloads: 35.8M
- License: Apache-2.0

## Runtime test results for web-vitals@6.2.1

Installed and executed on Sep 9, 2026 with require("web-vitals") from a CommonJS file and import "web-vitals" from an ES module.

| Runtime | require("web-vitals") | import "web-vitals" |
|---|---|---|
| Node.js 18 | works | works |
| Node.js 20 | works | works |
| Node.js 22 | works | works |
| Node.js 24 | works | works |
| Node.js 26 | works | works |
| Bun 1.4.0 | works | works |

## How to import web-vitals

ES modules:

```js
import * as webVitals from "web-vitals";
```

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

CommonJS:

```js
const webVitals = require("web-vitals");
```

## Module format by version

Derived from the type, main and exports fields of every stable release on npm (54 versions; the newest 54 shown).

| Versions | Format | First published |
|---|---|---|
| 3.0.0 – 6.2.1 | Dual (CommonJS + ESM) | Aug 24, 2022 |
| 0.2.2 – 2.1.4 | CommonJS | May 12, 2020 |
| 0.1.0 – 0.2.1 | ESM-only | Apr 24, 2020 |

## Frequently asked

**Is web-vitals ESM-only?**

web-vitals@6.2.1 ships CommonJS and ESM builds. web-vitals publishes both a CommonJS entry and a native ESM entry (ESM added in 0.1.0). require("web-vitals") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "web-vitals" works alongside it.

**Can I require web-vitals?**

Yes. web-vitals ships a CommonJS entry alongside the native ESM entry. require("web-vitals") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.

**Does web-vitals work in Bun?**

Yes. import "web-vitals" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does web-vitals ship TypeScript types?**

Yes. web-vitals bundles its own type declarations; no @types package is needed.

## Links

- [web-vitals on npm](https://www.npmjs.com/package/web-vitals)
- [Source repository](https://github.com/GoogleChrome/web-vitals)
- [HTML version](https://canirequire.com/package/web-vitals/)
- [JSON version](https://canirequire.com/package/web-vitals.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
