Search code examples
javascriptgoogle-chrome-extensionchromium

How can I check if a browser is Chromium-based?


I have a Chrome extension, and I am currently writing a website to advertise it. I know that a Chrome extension can be installed in all Chromium-based browsers (Chrome, Opera, etc.).

Is it possible to check if a browser can download the extension from the web store or is chromium-based?

I found code to detect if it was Google Chrome here. Correct me if I'm wrong, but I think window.chrome doesn't return in all Chromium-based browsers.


Solution

  • window.chrome

    As of now, window.chrome works in all chromium based browsers

    var isChromium = !!window.chrome;
    
    console.log(isChromium)

    Resources

    navigator.userAgentData

    User-Agent Client Hints API returns information about the browser and operating system of a user. (Introduced in chrome 90)

    var isChromium = !!navigator.userAgentData && navigator.userAgentData.brands.some(data => data.brand == 'Chromium');
    
    console.log(isChromium)

    Resources