ReactDOM APIs
The ReactDOM package provides DOM-specific methods that your components can import.
Most of your components should not need to import this module.
Installation
Terminal
npm install react-dom
// Importing a specific API:
import { createPortal } from 'react-dom';
// Importing all APIs together:
import * as ReactDOM from 'react-dom';
You’ll also need to install the same version of React.
Exports
Portals
createPortal
Create a portal.
createPortal(child, container);
Flushing
flushSync
Flush in progress updates.
flushSync(() => {
// ...
});
Deprecated
render
Displays a React component inside a browser DOM node (deprecated).
render(<App />, document.getElementById('root'));
hydrate
Hydrate server-rendered HTMl (deprecated).
hydrate(<App />, document.getElementById('root'));
Entry points
ReactDOMClient APIs
The ReactDOMClient APIs let you render React components in the browser.
import * as ReactDOMClient from 'react-dom/client';
ReactDOMServer APIs
The ReactDOMServer APIs let you render React components to HTML.
import * as ReactDOMServer from 'react-dom/server';