Search code examples
google-chrome-extensionmanifest.json

Display a favicon in a Chrome extension newtab page using manifest v3


I have recently migrated my chrome extension to manifest v3 using this guide: https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/

The v3 manifest.json file no longer supports using chrome://favicon/. Looking through the documentation I could not find an alternative. There were some articles I found that said it might be moved to a new favicon permission and be available under the google.favicon namespace. However they were all older and speculative, I tried these speculations to no avail.


Solution

  • The new API was just released as part of Chrome 104!

    To use it, first add the favicon permission to your manifest.json:

    {
        ...
        "permissions": ["favicon"],
        ...
    }
    

    Then you can load the favicon using your chrome extension's id, for example:

    const faviconSrc = `chrome-extension://${chrome.runtime.id}/_favicon/?pageUrl=${encodeURIComponent(url)}&size=32`;