• Chrome extensions
  • Installs
  • Analytics
  • Manifest V3

Detect if a Chrome extension is installed: 3 tested methods

How to detect if a Chrome extension is installed from your website: messaging, a content script handshake and resource probes, tested, with Edge and Firefox.

Author
Extenify Team
Published
Reading time
11 min read
A pile of colorful jigsaw puzzle pieces scattered on a table, some face up and some showing their plain cardboard backs

To detect if a Chrome extension is installed, your website has to ask the extension, and the extension has to agree to answer. There is no browser API a page can call to list installed extensions, and that is on purpose. What you can do is set up your own extension so that your own site can ask it "are you there, and which version are you?" There are three ways to do that, and they behave differently in Chrome, Edge, Firefox and Safari.

We built a small Manifest V3 extension, loaded it into Chromium 141 with Playwright, and ran each method against an allowed site and a site the extension does not know. This guide gives you the code that worked, the exact errors you see when the extension is missing, and how to use the answer for install tracking without collecting more data than you need.

Key takeaways

  • Messaging with externally_connectable is the cleanest method for Chrome and Edge: the page calls chrome.runtime.sendMessage(extensionId, ...) and the extension replies. Firefox does not support it for web pages.
  • When the extension is missing, the message fails with "Could not establish connection. Receiving end does not exist." On a site that no installed extension lists, chrome.runtime is not even defined.
  • A content script handshake through window.postMessage works in Chrome, Edge and Firefox, and needs no extension ID.
  • Probing a web-accessible file is the oldest trick and the weakest: it fails in Firefox, which uses a random per-install UUID, and in Chrome when the resource uses use_dynamic_url.
  • The same extension has a different ID on the Chrome Web Store and on Edge Add-ons, so a page that uses messaging must try both IDs.

Why your website needs to know

Detection is not a party trick. It is how you close the loop between your marketing site and the store:

  • Change the call to action. A visitor who already has the extension should see "Open the extension" or "What's new in 2.4", not another Add to Chrome button.
  • Attribute installs. The Chrome Web Store reports installs, but not which of your pages sent them. Knowing that a visitor arrived without the extension and came back with it lets you count installs per landing page, which complements the store's own conversion funnel.
  • Check update adoption. If the extension replies with its version, your site can tell you what share of returning visitors run the latest release, a useful sanity check after a rollout.
  • Gate onboarding. A setup page can wait until the extension is present, then continue.

All three methods below only work for an extension you control. A site cannot reliably detect someone else's extension, and with good reason, which we come back to in the FAQ.

The three methods at a glance

Method Chrome and Edge Firefox Safari Needs the extension ID Can return data
externally_connectable messaging Yes No Partly Yes Yes
Content script handshake Yes Yes Yes No Yes
Web-accessible resource probe Yes, unless use_dynamic_url No Not covered here Yes Only "present"

The Firefox and Safari columns come from MDN's browser compatibility data: Firefox has not implemented externally_connectable (bug 1319168), and Safari supports it from 15.4 but only the matches property. Our own tests covered Chromium only, so treat the Firefox and Safari behavior as documented, not measured.

Method 1: messaging with externally_connectable

This is the method Chrome documents in its messaging guide. The extension lists the sites that may talk to it, and those sites get a chrome.runtime.sendMessage that targets an extension ID.

Step 1: allow your site in the manifest

{
  "manifest_version": 3,
  "name": "My Extension",
  "version": "2.4.1",
  "background": { "service_worker": "sw.js" },
  "externally_connectable": {
    "matches": ["https://example.com/*", "https://www.example.com/*"]
  }
}

List every origin you will call from, including www and any staging domain. In our test, a page on https://www.example.com could not reach an extension that only listed https://example.com/*. Chrome's manifest reference also warns about a side effect: once you add the key, other extensions can only connect if you list them in ids too, so add "ids": ["*"] if another extension of yours relies on that.

Step 2: answer in the service worker

// sw.js: only these sites may ask whether the extension is installed.
const ALLOWED_ORIGINS = new Set(['https://example.com', 'https://www.example.com']);

chrome.runtime.onMessageExternal.addListener((message, sender, sendResponse) => {
  if (!sender.url || !ALLOWED_ORIGINS.has(new URL(sender.url).origin)) return;
  if (message?.type !== 'ping') return;
  sendResponse({ installed: true, version: chrome.runtime.getManifest().version });
});

Check the sender's origin even though the manifest already restricts it. If you later widen matches, the listener still refuses everything you did not plan for. Reply with the minimum: a flag and a version. Never return anything about the user.

Step 3: ask from the page

// The same extension has a different ID on each store.
const EXTENSION_IDS = [
  'abcdefghijklmnopabcdefghijklmnop', // Edge Add-ons ID
  'ponmlkjihgfedcbaponmlkjihgfedcba', // Chrome Web Store ID
];

async function getInstalledVersion(ids = EXTENSION_IDS, timeoutMs = 1000) {
  // Chrome only defines chrome.runtime here if an installed extension
  // lists this site in externally_connectable.
  const runtime = globalThis.chrome?.runtime;
  if (typeof runtime?.sendMessage !== 'function') return null;

  for (const id of ids) {
    try {
      const reply = await Promise.race([
        runtime.sendMessage(id, { type: 'ping' }),
        new Promise((resolve) => setTimeout(() => resolve(null), timeoutMs)),
      ]);
      if (reply?.installed) return reply.version;
    } catch {
      // Not installed under this ID: "Could not establish connection.
      // Receiving end does not exist."
    }
  }
  return null;
}

Replace the two IDs with your own. Edge Add-ons assigns its own ID when you publish there, which is easy to confirm: uBlock Origin's Chrome Web Store ID is cjpalhdlnbpafiamejdnhcphjbkeiagm, while its Edge Add-ons listing uses odfafepnkmbhccpbejgmiehpchacaeak. Our guide to the Chrome extension ID explains where to find each one and how to keep a development ID stable.

What we saw in testing

We loaded the extension into Chromium 141 through Playwright and served test pages on the allowed origin and on an unrelated one:

Situation Result
Allowed origin, correct ID { installed: true, version: '2.4.1' }
Allowed origin, wrong or missing ID Promise rejected: "Could not establish connection. Receiving end does not exist."
Same, using the callback form Callback called with undefined, and chrome.runtime.lastError set to the same message
www origin not listed in matches chrome.runtime undefined, function returned null
Unrelated origin chrome.runtime undefined, while chrome itself still existed

The last row is the most common source of confusion on Stack Overflow. typeof chrome !== 'undefined' is not a valid check, because Chrome defines a chrome object on every page. Check chrome.runtime.sendMessage instead, as the helper above does.

Method 2: a content script handshake

Content scripts run inside the page, so they can talk to page code through window.postMessage. This works in every browser that runs your extension, including Firefox, and it does not need the extension ID at all.

The content script

// marker.js: answer the page's ping on the sites listed in the manifest.
const SOURCE = 'my-extension';

document.documentElement.dataset.myExtensionVersion = chrome.runtime.getManifest().version;

window.addEventListener('message', (event) => {
  if (event.source !== window || event.origin !== window.location.origin) return;
  if (event.data?.source !== SOURCE || event.data.type !== 'ping') return;
  window.postMessage(
    { source: SOURCE, type: 'pong', version: chrome.runtime.getManifest().version },
    window.location.origin,
  );
});

Register it only on your own site:

"content_scripts": [
  {
    "matches": ["https://example.com/*", "https://www.example.com/*"],
    "js": ["marker.js"],
    "run_at": "document_start"
  }
]

The page side

function pingExtension(timeoutMs = 500) {
  return new Promise((resolve) => {
    const timer = setTimeout(() => {
      window.removeEventListener('message', onMessage);
      resolve(null);
    }, timeoutMs);

    function onMessage(event) {
      if (event.source !== window || event.data?.source !== 'my-extension') return;
      if (event.data.type !== 'pong') return;
      clearTimeout(timer);
      window.removeEventListener('message', onMessage);
      resolve(event.data.version);
    }

    window.addEventListener('message', onMessage);
    window.postMessage({ source: 'my-extension', type: 'ping' }, window.location.origin);
  });
}

In our test the handshake returned 2.4.1, and with run_at: document_start the data-my-extension-version attribute was already on the <html> element when an inline script in the page's <head> ran, in five out of five loads. The attribute is the fastest check for simple cases such as hiding an install button. The handshake is better when page code needs an answer at a specific moment, such as a route change in a single-page app, or when you want the extension to reply with more than a static flag.

One limit applies to both: in Chrome, manifest-declared content scripts run when a page loads, so a tab that was already open when the extension was installed does not get them. This comes up regularly in the Chromium Extensions group. A visitor who installs the extension and returns to an old tab of your site needs a reload, unless your onInstalled handler injects the script into matching tabs with chrome.scripting.executeScript. The simplest fix is a "Reload this page" hint after the install flow.

Two rules keep this safe. Chrome's messaging guide says to "assume that messages from a content script might have been crafted by an attacker", and the reverse is true here: any script on the page can post the same message. So the content script should answer with a version and nothing else, and it should never act on a page message by doing something privileged, such as calling your backend with the user's token.

Method 3: probing a web-accessible resource

The oldest method is to fetch() a file from inside the extension. If the request succeeds, the extension is installed.

"web_accessible_resources": [
  { "resources": ["installed.json"], "matches": ["https://example.com/*"] }
]
const installed = await fetch(`chrome-extension://${EXTENSION_ID}/installed.json`)
  .then((res) => res.ok)
  .catch(() => false);

In our test this returned the file when the extension was installed and failed with "Failed to fetch" for an unknown ID. It has three problems, though:

  • Chrome discourages it. Chrome's web_accessible_resources reference explains that no resources are exposed by default because this "allows a malicious website to fingerprint extensions that a user has installed".
  • use_dynamic_url breaks it. With "use_dynamic_url": true, the resource is only reachable through a per-session ID. In our test, runtime.getURL() returned a URL with a random GUID in place of the extension ID, and the fetch by extension ID failed.
  • Firefox never supports it. MDN's web_accessible_resources page notes that the moz-extension:// UUID "is randomly generated for every browser instance", precisely so sites cannot fingerprint installed extensions.

Use a resource probe only if you already expose a file for another reason and need a quick check. For anything new, use messaging or the handshake.

Which method should you use?

  • Chrome and Edge only, and you want the cleanest code: messaging with externally_connectable. Try the Edge ID and the Chrome ID in turn.
  • Firefox matters, or you do not want to manage IDs: the content script handshake. It is also the right choice for a Safari web extension.
  • Both: run the handshake first, because it covers every browser, and fall back to messaging if the content script is not injected (for example on a page the content script does not match).

Turn detection into install tracking

Detection becomes useful once you record it. A minimal setup that respects users' privacy:

  1. On the landing page, call the detector once per visit and send a single analytics event such as extension_detected with the version, or extension_missing. Do not attach it to a user profile unless the user is signed in and has agreed to that in your privacy policy.
  2. On install, open your welcome page from chrome.runtime.onInstalled with a source=install parameter, so the site knows the visit came from a fresh install. Our guide to chrome.runtime.onInstalled shows how to tell installs from updates.
  3. Compare the share of landing page visitors who return with the extension against the store's installs for the same period. If you use PostHog, our PostHog setup for Chrome extensions explains how to keep one ID between the site and the extension when the user consents.
  4. Do not count users from the site. Visitors to your site are a small, biased slice of your users. Weekly users, installs and uninstalls belong to the store dashboards; see how to measure retention and uninstall rate for that side.

The site tells you what happens on your pages. The stores tell you what happens everywhere else: installs, weekly users, ratings, reviews and the version each listing serves. Extenify tracks that public side for your Chrome, Edge and Firefox listings every day, next to your mobile apps, and alerts you by email, Slack, Telegram, Discord or Microsoft Teams when installs swing, a rating drops or a new version goes live. It works for competitors' listings too, since it only needs the store URL.

How to test detection automatically

You do not need a real domain to test this. We used Playwright's launchPersistentContext with --load-extension, then context.route() to answer requests for https://example.com/ with a local HTML page, so the page ran on an origin the manifest allows. Our guide to testing a Chrome extension with Playwright covers the launch setup. Test three cases every time you change the manifest: the allowed origin with the extension, the allowed origin with a wrong ID, and an origin that is not listed.

Frequently asked questions

Can a website see which extensions I have installed?

Not directly. There is no web API that lists extensions. A site can only detect an extension that chooses to answer it, or one that exposes files or changes the page in a recognizable way. Chrome's default of exposing no resources, dynamic resource URLs and Firefox's random extension UUIDs all exist to make that kind of fingerprinting harder.

Why is chrome.runtime undefined on my website?

Because no installed extension lists your page's origin in externally_connectable. Check that the exact origin, including www, a port or a staging subdomain, matches a pattern in the manifest, and that the extension version with that manifest is the one installed.

How do I detect my extension in Firefox?

Use the content script handshake. Firefox does not support externally_connectable for web pages, and its web-accessible resources use a random UUID per browser instance, so neither of the other methods works there.

Does the same code work in Microsoft Edge?

Yes. Edge runs Chromium extensions with the same APIs, but your Edge Add-ons listing has its own extension ID. Include it in the list of IDs the page tries.

Can I detect if a competitor's extension is installed?

Not reliably, and you should not try. Messaging only works if that extension lists your site, and probing other extensions' files is the fingerprinting that browsers are designed to block. To follow a competitor, watch their public store listing instead: users, rating, reviews and versions. To compare their rating with yours when the rating counts differ a lot, use a Bayesian average rating.

Summary

To detect if a Chrome extension is installed from your website, make your extension answer your site. Messaging with externally_connectable is the cleanest option for Chrome and Edge, as long as you list every origin and try both store IDs. A content script handshake works everywhere, including Firefox, and needs no ID. Resource probes are a last resort that browsers are actively closing off. Record the answer as a simple, consented analytics event, and read it next to the store's own install and user numbers.

Image credits

Put every store in one dashboard tonight.

Sign in with Google, paste one store link, and your unified view is live in under a minute. Then 7 days of Pro free, no credit card required, and you never touch your app's code.

Start free trial