create-react-app: How do I “npm start” with a specific browser?

This is possible with the BROWSER environment variable.

You can also do it directly in the terminal:
BROWSER=chrome npm start

This is described in the Advanced Configuration docs:

By default, Create React App will open the default system browser, favoring Chrome on macOS. Specify a browser to override this behavior, or set it to none to disable it completely. If you need to customize the way the browser is launched, you can specify a node script instead. Any arguments passed to npm start will also be passed to this script, and the url where your app is served will be the last argument. Your script’s file name must have the .js extension.

Also note that the browser names are different on different platforms:

The app name is platform dependent. Don’t hard code it in reusable modules. For example, Chrome is google chrome on macOS, google-chrome on Linux and chrome on Windows.

Leave a Comment