To install React on Ubuntu 26.04 or 24.04, create a React project with Vite and install its dependencies with npm. React is a JavaScript library for building interactive interfaces; Vite supplies the local development server and build tools.
React belongs to each project, not to Ubuntu as a system-wide application. Follow the steps below to set up Node.js, run a starter app and make a production build. If you need help, leave a comment or contact us.
From terminal to React app
Install the tools, start a local server and build your first project.
1. Set Up Node.js and npm
Node.js runs the development tools, and npm installs the packages they need. If you already have both, check them first:
Vite currently requires Node.js 20.19+ or 22.12+, and individual templates can require more. Node 20 has reached upstream end of life, so choose a supported LTS release that meets the current Vite requirements. Node.js 26 and 24 are LTS as of November 2026. Ubuntu 24.04’s default Node.js 18 package is too old for current Vite. If your existing version is compatible, skip to the project section.
For a new development setup, nvm installs Node.js for your user and lets you switch versions without replacing system packages. The full Node.js installation guide also covers Ubuntu packages and managing versions.
2. Create a React Project
3. Edit and Verify Your App
Open ~/react-demo/src/App.jsx in a text editor, such as Visual Studio Code. Replace its contents with this small component and save it:
With the development server running, the browser should update and show Hello from Ubuntu! The file contains JSX, a syntax that lets React describe what appears on the page. If you stopped the server, return to the project directory and run npm run dev again.
To check the installed React packages, open a second terminal and run the commands below. Alternatively, stop the development server with Ctrl+C and use the same terminal.
4. Build for Production
Stop the development server with Ctrl+C, then build and preview the optimized files locally:
A successful build writes static files to dist/. Open the local address printed by the preview command, then press Ctrl+C to stop it. Vite preview is a local check, not a production server. Deploy the contents of dist/ to a suitable static host; subdirectory deployments and client-side routes may need host configuration. See Vite static deployment.
This starter is a client-side app. React recommends a framework for many new production apps; routing, data loading and server rendering require additional decisions. See React’s framework guidance.
Do not put passwords, private API keys or other secrets in client-side code or VITE_ variables: they can be included in files sent to visitors. Keep private operations on a trusted server.
Troubleshooting
Update or Remove the Project
Run npm outdated and npm audit inside the project to review available updates and reported vulnerabilities. Review changes and test your app before upgrading; do not run a forced audit fix blindly. Keep Node and dependencies supported.
To remove this practice app, stop its server and back up anything you want to keep. Open your file manager, find react-demo in your home folder and move that folder to Trash. This removes the project and its local packages; it does not remove Node.js, nvm or other projects. Restore it from Trash if needed.
Helpful Resources
Continue with the React Quick Start and the Node.js release schedule.
Frequently Asked Questions
Is React installed system-wide?
No. This guide installs React and React DOM as dependencies of the individual project. Node.js is a separate runtime.
Do I need Node.js to use React in a browser?
The browser runs the built JavaScript. Node.js and npm are used on your development machine to install packages and build this project.
Should I use Create React App?
Create React App is deprecated for new apps. This guide uses Vite for a small learning project.
Can I use an existing React project?
Yes. Follow that project’s README and required Node version. Do not scaffold over its existing files.
Does removing the project uninstall Node.js?
No. Removing the project folder leaves Node.js, nvm and other projects in place.
Related guide: Install a LEMP stack on Ubuntu.
