Can you use Create-React-App npm start with nodejs?

Viewed 682

I'm very new to React and node.js.

I want to run a node.js server that serves up React.js pages/views.

When I use 'create-react-app' and then 'npm start' do I need to then start my node server as well, or do I need to use 'npm run build' before it will work with the node.js server?

I like how it auto-updates your react.js pages after 'npm start' when you make changes to the code.

I'm just wondering if I have to run the 'npm run build' command every time I make a change.

Thanks for any help!

1 Answers

No, you don't need to run npm run build command each time as this command is used when you're ready to ship your code to production environment.

In a create-react-app project, you get hot reloading out of the box when developing locally (after running npm start). In other words, when the local server is running, every time you make a change the browser will automatically reload.


From the create-react-app documentation:

npm start: Runs the app in the development mode. Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits. You will also see any lint errors in the console.

https://create-react-app.dev/docs/available-scripts#npm-start

Related