Skip to content

Browser API

epos.browser provides access to chrome.* APIs in every context of your extension.

Normally, you cannot access chrome.* from web pages or iframes. In isolated content scripts, access is also very limited. Epos removes these boundaries and lets you use the same APIs from any context.

Why epos.browser and not epos.chrome?

There are two reasons for the name:

  1. There is an ongoing effort to standardize the extensions API, and browser is the common name used for it.

  2. chrome sounds Chrome-specific, but Epos also works with other Chromium browsers, including Edge and Brave. In that context, browser is a better fit.

The Same API

epos.browser does not give you a new API to learn. For supported APIs, it is a one-to-one mirror of chrome.*. For example:

ts
const tabs = await epos.browser.tabs.query({ active: true })

epos.browser.windows.onCreated.addListener(window => {
  console.log('New window:', window.id)
})

If you know how to use chrome.*, you already know how to use epos.browser.*.

epos.browser is fully typed, so you get autocompletion and type checking in your editor. For general API behavior, see the Chrome Extensions API reference or the MDN version.

Permissions Still Apply

epos.browser does not bypass the extension's permission system. If an API requires a permission, it still requires that permission when accessed via epos.browser.

For example, epos.browser.downloads.* needs the downloads permission, and epos.browser.cookies.* needs the cookies permission.

To request or inspect permissions at runtime, use epos.browser.permissions:

ts
const granted = await epos.browser.permissions.request({
  permissions: ['downloads'],
})

if (granted) {
  await epos.browser.downloads.download({
    url: 'https://example.com/file.txt',
    filename: 'file.txt',
  })
}
json
{
  "name": "My Extension",
  "optionalPermissions": ["downloads"],
  "matches": "<popup>",
  "load": "main.js"
}

To learn more about supported permissions, see the Permissions guide.

Supported APIs

epos.browser does not expose the full set of chrome.* APIs, but it does include the most commonly used ones:

  • action
  • alarms
  • browsingData
  • contextMenus
  • cookies
  • declarativeNetRequest
  • downloads
  • extension
  • i18n
  • management
  • notifications
  • permissions
  • runtime
  • sidePanel
  • storage
  • tabs
  • webNavigation
  • windows