How to deploy React App with Express

Hey guy, Today I write a little tutorial for deploy project in React app and Express

Create new React app and Express app

create-react-app my-app
express my-server

After create project, we will change a little in folder my-server

  • Add folder client with purpose using for insert project my-app

So Architecture directory should be

|--- bin
|--- client
     |--- public
     |--- src 
     |--- .gitignore
     |--- package.json
|--- public/stylesheets
|--- routes
|--- views
|--- app.js
|--- package.json
|--- .gitignore

Configuration for package.json in my-server

{
  "name": "server",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "nodemon ./bin/www",
    "heroku-postbuild": "cd client && npm install && npm run build"
  },
  "dependencies": {
    "cookie-parser": "~1.4.4",
    "debug": "~2.6.9",
    "express": "~4.16.1",
    "http-errors": "~1.6.3",
    "jade": "~1.11.0",
    "morgan": "~1.9.1",
    "nodemon": "^1.19.3"
  }
}

I hope post will useful with you 😁

Last updated

Was this helpful?