Enabling HTTPS on localhost when running Create React App (CRA) locally

Create React App (CRA) is convenient and easy way to setup initial boiler plate when developing React App.

To start building React App using CRA, we generally use following steps to start setup and run default CRA app.

npx create-react-app my-app
cd my-app
npm start

After running these steps we will generally see the React app running locally on http://localhost:3000. But when we deploy and run app on production we mostly host on HTTPS. So, the question is how do we test the app locally on https.

This is very easy to setup, just run Set HTTPS=true before running npm start or yarn start. Alternavely you can update the npm scripts into packages.json

“start”: “set HTTPS=true&react-scripts start”

When we run npm start or yarn start we will see React app will launched on https://localhost:3000.

Enabling HTTPS on localhost when running Create React App (CRA) locally