npm install react-dom

React package for working with the DOM.

About react-dom

React-DOM is an essential npm package for developers utilizing React, a popular JavaScript library for building user interfaces. As a crucial part of the React ecosystem, React-DOM provides efficient methods for rendering UI components in web browsers. Its primary function is to interact with the Document Object Model (DOM), enabling seamless integration of React components into the DOM tree. This package ensures that developers can manage and manipulate the browser's DOM effectively, allowing for dynamic and responsive web applications. The performance optimizations embedded in React-DOM make it a vital tool for modern web development, ensuring fast and smooth user experiences.

For developers looking to leverage React in their projects, the process begins with a simple command: npm install react-dom. This command facilitates the installation of the React-DOM package, integrating it into your project environment swiftly. By running `npm install react-dom`, developers are equipped with the necessary tools to bridge React's virtual DOM with the actual browser DOM. This installation is crucial as it allows React to efficiently update the DOM only when necessary, reducing the performance costs associated with DOM manipulation. The npm package management system ensures that this process is both straightforward and manageable, allowing developers to focus more on creating engaging and interactive web applications.

The benefits of using React-DOM extend beyond just improved performance and easy integration. It supports a wide range of development needs, from simple single-page applications to complex, large-scale enterprise-level systems. With React-DOM, developers can harness the full potential of React's declarative programming style, enhancing code stability and maintainability. Additionally, React-DOM is maintained by a vibrant community of developers, ensuring it stays up-to-date with the latest web technologies and best practices. This community also provides extensive support through documentation and forums, making React-DOM an indispensable tool for developers aiming to craft cutting-edge web applications.

More from facebook

facebook npm packages

Find the best node modules for your project.

Search npm

react-is

Brand checking of React Elements...

Read more
,

react

React is a JavaScript library for building user interfaces...

Read more
,

react-dom

React package for working with the DOM...

Read more
,

fb-watchman

Bindings for the Watchman file watching...

Read more
,

eslint-plugin-react-hooks

ESLint rules for React...

Read more
,

facebook-nodejs-business-sdk

SDK for the Facebook Marketing API in Javascript and Node...

Read more
,

react-facebook-auth

A Component React for Facebook...

Read more
,

facebook-locales

Maps locales to Facebook...

Read more

Dependencies

Core dependencies of this npm package and its dev dependencies.

@babel/cli, @babel/code-frame, @babel/core, @babel/helper-module-imports, @babel/parser, @babel/plugin-external-helpers, @babel/plugin-proposal-class-properties, @babel/plugin-proposal-object-rest-spread, @babel/plugin-syntax-dynamic-import, @babel/plugin-syntax-import-meta, @babel/plugin-syntax-jsx, @babel/plugin-syntax-typescript, @babel/plugin-transform-arrow-functions, @babel/plugin-transform-block-scoped-functions, @babel/plugin-transform-block-scoping, @babel/plugin-transform-classes, @babel/plugin-transform-computed-properties, @babel/plugin-transform-destructuring, @babel/plugin-transform-for-of, @babel/plugin-transform-literals, @babel/plugin-transform-modules-commonjs, @babel/plugin-transform-object-super, @babel/plugin-transform-parameters, @babel/plugin-transform-react-jsx, @babel/plugin-transform-react-jsx-development, @babel/plugin-transform-react-jsx-source, @babel/plugin-transform-shorthand-properties, @babel/plugin-transform-spread, @babel/plugin-transform-template-literals, @babel/preset-flow, @babel/preset-react, @babel/traverse, @rollup/plugin-babel, @rollup/plugin-commonjs, @rollup/plugin-node-resolve, @rollup/plugin-replace, abortcontroller-polyfill, art, babel-plugin-syntax-trailing-function-commas, chalk, cli-table, coffee-script, confusing-browser-globals, core-js, create-react-class, danger, error-stack-parser, eslint, eslint-config-prettier, eslint-plugin-babel, eslint-plugin-eslint-plugin, eslint-plugin-ft-flow, eslint-plugin-jest, eslint-plugin-no-for-of-loops, eslint-plugin-no-function-declare-after-return, eslint-plugin-react, eslint-plugin-react-internal, fbjs-scripts, filesize, flow-bin, flow-remove-types, glob, glob-stream, google-closure-compiler, gzip-size, hermes-eslint, hermes-parser, jest, jest-cli, jest-diff, jest-environment-jsdom, jest-snapshot-serializer-raw, minimatch, minimist, mkdirp, ncp, prettier, prettier-2, pretty-format, prop-types, random-seed, react-lifecycles-compat, rimraf, rollup, rollup-plugin-prettier, rollup-plugin-strip-banner, semver, shelljs, signedsource, targz, through2, tmp, typescript, undici, web-streams-polyfill, yargs

Documentation

A README file for the react-dom code repository. View Code

react-dom

This package serves as the entry point to the DOM and server renderers for React. It is intended to be paired with the generic React package, which is shipped as react to npm.

Installation

npm install react react-dom

Usage

In the browser

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

function App() {
  return <div>Hello World</div>;
}

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

On the server

import { renderToPipeableStream } from 'react-dom/server';

function App() {
  return <div>Hello World</div>;
}

function handleRequest(res) {
  // ... in your server handler ...
  const stream = renderToPipeableStream(<App />, {
    onShellReady() {
      res.statusCode = 200;
      res.setHeader('Content-type', 'text/html');
      stream.pipe(res);
    },
    // ...
  });
}

API

react-dom

See https://react.dev/reference/react-dom

react-dom/client

See https://react.dev/reference/react-dom/client

react-dom/server

See https://react.dev/reference/react-dom/server