DEV Community

Cover image for How to Render React with express.js together
Shuhaib S
Shuhaib S

Posted on

How to Render React with express.js together

Hi guys, this is a way to run the react and express in a single server and a static way

  1. Create a react project and write your code.
  2. Create an express project.
  3. Run the express project.
  4. Link the express backend with react and build.
  5. Set the react project build folder as static in the express.
  6. And re-run the express project.
 app.use(express.static(path.join(__dirname, 'build')))
Enter fullscreen mode Exit fullscreen mode

working
The react project will be bundled together through the build. And it will contain an HTML file so the HTML file will be rendered when the express project run. So the HTML file will available for the end user and

Top comments (2)

Collapse
 
georgerowe profile image
GeorgeRowe

This site gives us many information to solve error form our site! Thanks buddy to share this great amazing information! dua for something you really want

Collapse
 
muhseenat profile image
Muhseena T

Really nice