Skip to content
Tutorials Center
My learning

Topics

React Reference ยท react-dom Client APIs

ReactDOM.version

Reference for the version export of react-dom: read the installed react-dom version string at runtime, compare it with react, and gate code by major version.

version is a string export that tells you which release of react-dom is loaded, for example "19.3.1". It follows semantic versioning (major.minor.patch, optionally followed by a pre-release tag such as -canary-abc123). The same export exists on react-dom/client, react-dom/server and react-dom/static, and all of them hold the same value for one installed package.

Most apps never need it. It is handy in bug reports, in developer tools, in libraries that must work with several React majors, and when you are not sure which build an environment (a CDN import, a sandbox, a monorepo) is really serving.

JSX
import { version } from 'react-dom';

console.log(version); // "19.3.1"

Try it

Which versions are loaded?
Gate a feature by version and by capability

On React 19 the table shows true, true, function, function and undefined: the legacy ReactDOM.render is gone.

Syntax

JSX
import { version } from 'react-dom';
TypeScript
const version: string;
Name Description
version Read-only string such as "19.3.1". Not a function; do not call it.

Returns: the string itself. Errors / edge cases: none at runtime. In bundles where tree shaking or aliasing replaces react-dom, check that the value is a string before parsing it.

Usage notes

  • Parse it, don't compare strings. "19.10.0" > "19.9.0" is false as text. Split on . and compare numbers, or use a semver library.
  • Prefer feature detection. typeof ReactDOM.preload === 'function' says more than a version check, and keeps working in forks and canary builds whose numbers look unusual.
  • Match react and react-dom. They are released together and must have the same version. A mismatch (say react 19.3.1 with react-dom 19.2.0) produces confusing errors; comparing the two version strings is the quickest check.
  • Several copies. In a large app two copies of react-dom can end up in the bundle. If hooks fail with "invalid hook call", log version from where each copy is imported.
  • Canary and experimental builds carry a suffix after the numbers. Treat anything after the first - as pre-release.
  • Not for user-facing logic. Showing a version in an About dialog is fine; branching business behaviour on it is a smell.
  • The sibling export for React itself is React.version; see React.version.