react-dom
React package for working with the DOM.
Last updated 2 years ago by react-bot .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install react-dom 
SYNC missed versions from official npm registry.

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

Current Tags

  • 18.0.0-beta-24dd07bd2-20211208                                ...           beta (4 years ago)
  • 19.0.0-rc-7c8e5e7a-20241101                                ...           canary (a year ago)
  • 0.0.0-experimental-a8964649b                                ...           experimental (5 years ago)
  • 19.2.5                                ...           latest (3 days ago)
  • 19.0.0-rc-7c8e5e7a-20241101                                ...           next (a year ago)
  • 19.0.0-rc.1                                ...           rc (a year ago)

887 Versions

Maintainers (2)
Downloads
Today 1
This Week 4
This Month 20
Last Day 0
Last Week 131
Last Month 870
Dependencies (2)
Dev Dependencies (0)
None
Dependents (124)

Copyright 2013 - present © cnpmjs.org | Home |