canirequire

canirequireCommonJS › @testing-library/react-hooks

Is @testing-library/react-hooks ESM-only? Can you require() it?

Simple and complete React hooks testing utilities that encourage good testing practices.

Last verified Sep 9, 2026 against @testing-library/react-hooks@8.0.1. JSON

CommonJS CommonJS — require() works on every Node.js version

@testing-library/react-hooks ships CommonJS only. require("@testing-library/react-hooks") works everywhere. import "@testing-library/react-hooks" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Latest
8.0.1 (Jun 18, 2022)
Module format
CommonJS
Last CommonJS version
8.0.1
TypeScript types
Bundled
Node engines
>=12
Weekly downloads
2.4M
License
MIT

Does @testing-library/react-hooks@8.0.1 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("@testing-library/react-hooks") from a CommonJS file and import "@testing-library/react-hooks" from an ES module.

Runtimerequire("@testing-library/react-hooks")import "@testing-library/react-hooks"
Node.js 18✗ failsError: Could not auto-detect a React renderer. Are you sure you've installed one of the following✗ failsError: Could not auto-detect a React renderer. Are you sure you've installed one of the following
Node.js 20✗ failsError: Could not auto-detect a React renderer. Are you sure you've installed one of the following✗ failsError: Could not auto-detect a React renderer. Are you sure you've installed one of the following
Node.js 22✗ failsError: Could not auto-detect a React renderer. Are you sure you've installed one of the following✗ failsError: Could not auto-detect a React renderer. Are you sure you've installed one of the following
Node.js 24✗ failsError: Could not auto-detect a React renderer. Are you sure you've installed one of the following✗ failsError: Could not auto-detect a React renderer. Are you sure you've installed one of the following
Node.js 26✗ failsError: Could not auto-detect a React renderer. Are you sure you've installed one of the following✗ failsError: Could not auto-detect a React renderer. Are you sure you've installed one of the following
Bun 1.4✗ failserror: Could not auto-detect a React renderer. Are you sure you've installed one of the following✗ failserror: Could not auto-detect a React renderer. Are you sure you've installed one of the following

A failing require() on a CommonJS package usually means the package needs a browser/DOM global, a peer dependency, or a native binary that is not available in a bare Node.js process.

How to import @testing-library/react-hooks

ES modules (import)

import reactHooks from "@testing-library/react-hooks";

Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.

CommonJS (require)

const reactHooks = require("@testing-library/react-hooks");

Module format by version

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

VersionsFormatFirst published
1.0.0 – 8.0.1CommonJSJun 19, 2019

Frequently asked

Is @testing-library/react-hooks ESM-only?

@testing-library/react-hooks@8.0.1 is a CommonJS package. @testing-library/react-hooks ships CommonJS only. require("@testing-library/react-hooks") works everywhere. import "@testing-library/react-hooks" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Can I import @testing-library/react-hooks with ES module syntax?

Yes. import reactHooks from "@testing-library/react-hooks" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.

Does @testing-library/react-hooks work in Bun?

Importing @testing-library/react-hooks failed in Bun 1.4 on Sep 9, 2026: error: Could not auto-detect a React renderer. Are you sure you've installed one of the following

Does @testing-library/react-hooks ship TypeScript types?

Yes. @testing-library/react-hooks bundles its own type declarations; no @types package is needed.

Links

Other commonjs packages

Similar popularity