# Is class-variance-authority ESM-only? Can you require() it?

> class-variance-authority@0.7.1 ships CommonJS and ESM builds. Dual package — require() works on every Node.js version we test; import works too.

Class Variance Authority 🧬

Last verified Sep 9, 2026 against class-variance-authority@0.7.1.

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

## What to do

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

## Facts

- Latest: 0.7.1 (Nov 26, 2024)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 0.7.1
- Native ESM since: 0.5.0
- TypeScript types: bundled
- Node engines: not declared
- Weekly downloads: 54.3M
- License: Apache-2.0

## Runtime test results for class-variance-authority@0.7.1

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

| Runtime | require("class-variance-authority") | import "class-variance-authority" |
|---|---|---|
| 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 class-variance-authority

ES modules:

```js
import * as classVarianceAuthority from "class-variance-authority";
```

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

CommonJS:

```js
const classVarianceAuthority = require("class-variance-authority");
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 0.5.0 – 0.7.1 | Dual (CommonJS + ESM) | Apr 2, 2023 |
| 0.0.0 – 0.4.0 | CommonJS | Jan 26, 2022 |

## Frequently asked

**Is class-variance-authority ESM-only?**

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

**Can I require class-variance-authority?**

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

**Does class-variance-authority work in Bun?**

Yes. import "class-variance-authority" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does class-variance-authority ship TypeScript types?**

Yes. class-variance-authority bundles its own type declarations; no @types package is needed.

## Links

- [class-variance-authority on npm](https://www.npmjs.com/package/class-variance-authority)
- [Source repository](https://github.com/joe-bell/cva)
- [HTML version](https://canirequire.com/package/class-variance-authority/)
- [JSON version](https://canirequire.com/package/class-variance-authority.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.
