Skip to content

Instantly share code, notes, and snippets.

@SAADIQBAL19114
Last active January 24, 2024 14:39
Show Gist options
  • Save SAADIQBAL19114/5622750f91313baf10c166d46bea02a4 to your computer and use it in GitHub Desktop.
Save SAADIQBAL19114/5622750f91313baf10c166d46bea02a4 to your computer and use it in GitHub Desktop.
how to deploy a react app on the surge

Deploying a React app with Surge (from Create React App format)

1. Make sure you have surge installed globally

  • npm install -g surge

2. Run the Create React App build

  • cd your-react-project
  • npm run build

3. Change into build directory

  • cd build

4. Run surge

  • surge
  • Log in with your email and password, hit enter
  • Enter the correct path to your project, hit enter
  • Change the url to your custom url or use the default, hit enter
  • Surge will run deploy

Adding deploy script to package.json

  • In package.json under "scripts" add this line:
  • "deploy": "npm run build && surge ./build/ your-surge-url.surge.sh"
  • Update your-surge-url with your url
  • npm run deploy (this will need to be run from your project root, not the build directory!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment