How to View React App in Browser: Quick Start
In this article
To view your React app in a browser, you run a development server that compiles your code and serves it locally. The default command is npm start (or yarn start), which opens http://localhost:3000 automatically. This guide covers the exact steps for both newly created and existing React projects, plus common pitfalls and fixes.
What You'll Need
- Node.js (version 14 or later recommended) installed on your computer. Check with
node -v. - npm or yarn package manager (npm comes with Node.js).
- A React project folder — either created with
create-react-appor set up manually (e.g., with Vite). - A code editor (optional but helpful) like VS Code.
Step-by-Step
- Open a terminal (Command Prompt, PowerShell, or Terminal) in your project's root directory. The root directory is the folder containing
package.json. - Install dependencies (if not already done). Run
npm installoryarn install. This creates anode_modulesfolder. Skip if you just rancreate-react-app. - Start the development server. Run
npm start(oryarn start). For Vite projects, the command isnpm run dev. - Wait for the compilation. You'll see output like "Compiled successfully!" or "VITE ready". The terminal will display a local URL (usually
http://localhost:3000for Create React App, orhttp://localhost:5173for Vite). - Open the browser. If it doesn't open automatically, manually type the URL from the terminal into your browser's address bar. For Create React App, it's
http://localhost:3000. - View your app. You should see the default React welcome page (or your own components if you've edited the code). Any changes you make to the source files will hot-reload automatically.
- Stop the server when done. Press
Ctrl+Cin the terminal (orCmd+Con Mac) and confirm withyif prompted.
Common Mistakes
- Running the command in the wrong folder — if you're not in the project root,
npm startwill fail with "missing script: start". - Forgetting to install dependencies — running
npm startbeforenpm installgives an error about missing modules. - Port already in use — if port 3000 is occupied, the server will prompt you to use another (e.g., 3001). Accept it or close the other process.
- Using the wrong command for Vite — Vite projects use
npm run dev, notnpm start. - Editing files in
public/instead ofsrc/— changes topublic/index.htmlmay not trigger hot reload; you might need to refresh manually.
Tips
- Use the browser's developer tools (F12) to inspect the React component tree — install the React DevTools extension for Chrome or Firefox to see props and state.
- Keep the terminal visible while developing; errors and warnings appear there and are often more detailed than in the browser console.
- Use
npm run buildfor production — this creates an optimizedbuildfolder that you can serve with any static server. But for daily development,npm startis faster. - Set a custom port if needed:
npm start -- --port 5000(for Create React App) or setPORTenvironment variable. - If hot reload seems stuck, refresh the browser manually. Sometimes the websocket connection drops.
Troubleshooting
- "'npm' is not recognized as internal or external command" — Node.js is not installed or not in your PATH. Download and install Node.js from nodejs.org, then restart your terminal.
- "Module not found: Can't resolve 'react'" — dependencies are missing. Run
npm installagain. - Browser shows a blank white page — check the browser console (F12) for errors. Common causes: syntax error in your code, or you're running the app from a different directory than the project root.
- Port 3000 is already in use — the terminal will ask "Would you like to run the app on another port instead?" Type
y. Alternatively, close the other process (e.g., another React app). - Changes not appearing after editing — make sure you're editing files in
src/, not thebuildfolder. Also check that the terminal shows "Compiled successfully" after saving. - App loads but shows an error overlay — read the error message in the red overlay; it usually points to the exact file and line. Fix the error and save; the overlay clears.
Frequently Asked Questions
Why does my browser open to a different port than 3000?
If port 3000 is already in use, Create React App automatically uses the next available port (3001, 3002, etc.). The terminal will show the correct URL.
Can I view my React app on my phone?
Yes. Ensure your phone and computer are on the same Wi-Fi. In the terminal, you'll see a "Network" URL like http://192.168.1.5:3000. Enter that on your phone's browser.
What is the difference between npm start and npm run build?
npm start runs a development server with hot reload, optimized for coding. npm run build creates a production-ready static bundle in a build folder that you can deploy to a web server.
How do I view my React app if I'm using Vite instead of Create React App?
For Vite, run npm run dev (or yarn dev). The terminal will show a local URL, usually http://localhost:5173.
Why does my app show a blank page after I open it?
Check the browser's developer console for errors. A common cause is an uncaught exception in your JavaScript. Also verify that your index.js correctly renders the root component to the root element.
Do I need to restart the server after editing code?
No. The development server automatically recompiles and reloads the page when you save changes. If it doesn't, try refreshing manually or restarting the server.