Framework24M+/wkMIT

react-dom

React DOM is the package that provides DOM-specific methods for React, serving as the entry point to the DOM and server renderers. While the react package conta

Installation

npm
npm install react-dom
yarn
yarn add react-dom
pnpm
pnpm add react-dom

Import

ESM
import { createRoot } from 'react-dom/client';

Quick Example

usage
import { createRoot } from 'react-dom/client';
import App from './App';

const root = createRoot(
  document.getElementById('root')
);
root.render(<App />);

About react-dom

React DOM is the package that provides DOM-specific methods for React, serving as the entry point to the DOM and server renderers. While the react package contains the core library for defining components and managing state, react-dom handles the actual rendering of those components to the browser DOM or to HTML strings for server-side rendering. The package exports the createRoot function for mounting React applications to a DOM container element, hydrateRoot for hydrating server-rendered HTML, and various utilities for portals and event handling. React DOM also includes the server rendering APIs through react-dom/server, providing renderToString, renderToStaticMarkup, and the streaming renderToPipeableStream and renderToReadableStream methods for Node.js and web streams respectively. This separation between react and react-dom was introduced in React 0.14 to enable React Native and other renderers to share the core react package. React DOM handles browser-specific concerns like event delegation, attribute mapping, and DOM element creation while React handles component logic and reconciliation.

Quick Facts

Packagereact-dom
CategoryFramework
Weekly Downloads24M+
LicenseMIT
Installnpm install react-dom

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.