Harbin Ramo
Harbin R


Harbin R


React: Change my port!

Harbin Ramo's photo
Harbin Ramo
ยทJan 6, 2021ยท

1 min read

Hello! On this article, I want to share what I have found on changing ports in React. In Express, its easy to declare any port number by assigning it to a constant variable:

In ExpressJS:

import express from 'express';

const app = express();
const PORT = <any number>;

In React:

  • Go to package.json file.


  • Under scripts line, modify the command on start and save (Ctrl+S).
"scripts": {
    "start": "set PORT=8000 && react-scripts start",
    "build": "react-scripts build"
  • After modifying start, go to Terminal (Ctrl+~) --> npm start --> hit Enter (if your app is in another folder, type in cd <folder name>, hit Enter then type in npm start --> hit Enter).


  • When viewed in browser, it will now look like this:


Aaaaaand that's it! ๐Ÿ˜„

Share this