Last modified: Jul 20, 2025 By Alexander Williams
Install React-DOM in Node.js - Quick Guide
React-DOM is a crucial module for React applications. It helps render React components in the browser. This guide will show you how to install it in Node.js.
Prerequisites
Before installing react-dom, ensure you have Node.js installed. You'll also need npm or yarn. If you're new to React, check our guide on How to Install React in Node.js.
Install React-DOM
Open your terminal and navigate to your project directory. Run the following command:
npm install react-dom
If you prefer yarn, use:
yarn add react-dom
Verify Installation
After installation, check your package.json file. You should see react-dom listed under dependencies.
"dependencies": {
"react-dom": "^18.2.0"
}
Import React-DOM
To use react-dom in your project, import it in your JavaScript file:
import ReactDOM from 'react-dom/client';
Basic Usage Example
Here's a simple example of how to use react-dom to render a React component:
import React from 'react';
import ReactDOM from 'react-dom/client';
function App() {
return <h1>Hello World!</h1>;
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);
Troubleshooting
If you encounter errors, ensure your React version is compatible. You might also need to configure Babel. Check our guide on Install Babel-ESLint in Node.js for help.
Conclusion
Installing react-dom in Node.js is simple. Just use npm or yarn and import it in your project. For more Node.js tips, see our guide on How to Install Nodemon in Node.js.