Why is chrome.browserAction.onClicked undefined?

Classic ManifestV2

For those who already have added something like

"background": {
    "scripts": ["background.js"]
}

and still gets Cannot read property 'onClicked' of undefined – just add

"browser_action": {}

into your manifest.json

ManifestV3

manifest.json: use action not browser_action, see also the migration guide.

"background": {"service_worker": "background.js"}
"action": {}

background.js: use chrome.action not chrome.browserAction.

Leave a Comment