How to change default browser of cordova browser platform?

Test the following command:

cordova run browser --target=firefox


The only way to change the default Chrome browser is using the --target option.

As you can see Chrome is the default browser for the run command.

Internally, the cordovaServe.launchBrowser function is called with cli arguments.

This function is defined in the cordova-serve/serve.js file and you can find its body in the cordova-serve/src/browser.js file where you can find the complete list of supported browsers for each platform:

var browsers = {
    'win32': {
        'ie': 'iexplore',
        'chrome': 'chrome --user-data-dir=%TEMP%\\' + dataDir,
        'safari': 'safari',
        'opera': 'opera',
        'firefox': 'firefox',
        'edge': 'microsoft-edge'
    },
    'darwin': {
        'chrome': '"Google Chrome" --args' + chromeArgs,
        'safari': 'safari',
        'firefox': 'firefox',
        'opera': 'opera'
    },
    'linux' : {
        'chrome': 'google-chrome' + chromeArgs ,
        'chromium': 'chromium-browser' + chromeArgs,
        'firefox': 'firefox',
        'opera': 'opera'
    }
};

I hope that this answer will help you to learn a bit more about cordova and the way it works.

Tags:

Cordova