Files
electron/docs/api/extensions.md
T
claude[bot]andClaude Opus 5.5 2fb6c26db6 feat: support chrome.storage.sync in extensions (#54088)
* feat: support chrome.storage.sync in extensions

Register a ValueStoreCache for the SYNC settings namespace from
ElectronExtensionsAPIClient::AddAdditionalValueStoreCaches. Until now
Electron never overrode that hook, so StorageFrontend only knew about
LOCAL (and the in-memory SESSION area) and every chrome.storage.sync
call failed with '"sync" is not available in this instance of Chrome'.

ElectronSyncValueStoreCache mirrors Chromium's LocalValueStoreCache but
uses settings_namespace::SYNC, which gives it its own LevelDB directory
under the partition path (kSyncExtensionSettingsDirectoryName), so sync
and local never alias. It enforces the chrome.storage.sync quotas from
extensions/common/api/storage.json (QUOTA_BYTES 102400,
QUOTA_BYTES_PER_ITEM 8192, MAX_ITEMS 512); the per-minute and per-hour
write limits are already applied to kSync by storage_api.cc. There is
no sync service in Electron, so the area behaves like Chrome with sync
disabled: a second local store with no cross-device sync.
chrome.storage.managed stays unsupported because there is no policy
source to back it.

This answers the question raised on #53995 about supporting
chrome.storage instead of dropping sync from the test fixture.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFucMLGyVVqSUAKXrqbaUT

* fix: include value_store_factory.h in ElectronExtensionsAPIClient

The linux-x64 and linux-x64-ubsan builds failed compiling
electron_extensions_api_client.cc:

  ../../base/memory/scoped_refptr.h:398:6: error: member access into
  incomplete type 'value_store::ValueStoreFactory'
  ../../base/memory/scoped_refptr.h:405:6: error: member access into
  incomplete type 'value_store::ValueStoreFactory'
  note: in instantiation of ... requested here
    electron_extensions_api_client.cc:97:39:
      new ElectronSyncValueStoreCache(factory);

AddAdditionalValueStoreCaches copies the
scoped_refptr<value_store::ValueStoreFactory> into the new
ElectronSyncValueStoreCache, which instantiates AddRef/Release on the
pointee. extensions_api_client.h and electron_sync_value_store_cache.h
only forward-declare ValueStoreFactory, so the translation unit needs
the full definition. Include components/value_store/value_store_factory.h
the same way chrome_extensions_api_client.cc does.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFucMLGyVVqSUAKXrqbaUT

* test: use vitest matchers in chrome.storage.sync spec

main dropped chai in favour of vitest's own matchers and now lints
against chai-style chains, so convert the chrome.storage.sync spec's
assertions to the equivalent vitest matchers.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFucMLGyVVqSUAKXrqbaUT

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-23 09:16:18 -04:00

5.8 KiB

Chrome Extension Support

Electron supports a subset of the Chrome Extensions API, primarily to support DevTools extensions and Chromium-internal extensions, but it also happens to support some other extension capabilities.

Note

Electron does not support arbitrary Chrome extensions from the store, and it is a non-goal of the Electron project to be perfectly compatible with Chrome's implementation of Extensions.

Loading extensions

Electron only supports loading unpacked extensions (i.e., .crx files do not work). Extensions are installed per-session. To load an extension, call ses.extensions.loadExtension:

const { session } = require('electron')

session.defaultSession.loadExtension('path/to/unpacked/extension').then(({ id }) => {
  // ...
})

Loaded extensions will not be automatically remembered across exits; if you do not call loadExtension when the app runs, the extension will not be loaded.

Note that loading extensions is only supported in persistent sessions. Attempting to load an extension into an in-memory session will throw an error.

See the session documentation for more information about loading, unloading, and querying active extensions.

Supported Extensions APIs

We support the following extensions APIs, with some caveats. Other APIs may additionally be supported, but support for any APIs not listed here is provisional and may be removed.

Supported Manifest Keys

  • name
  • version
  • author
  • permissions
  • content_scripts
  • default_locale
  • devtools_page
  • short_name
  • host_permissions (Manifest V3)
  • manifest_version
  • background (Manifest V2)
  • minimum_chrome_version

See Manifest file format for more information about the purpose of each possible key.

chrome.devtools.inspectedWindow

All features of this API are supported.

See official documentation for more information.

chrome.devtools.network

All features of this API are supported.

See official documentation for more information.

chrome.devtools.panels

All features of this API are supported.

See official documentation for more information.

chrome.extension

The following properties of chrome.extension are supported:

  • chrome.extension.lastError

The following methods of chrome.extension are supported:

  • chrome.extension.getURL
  • chrome.extension.getBackgroundPage

See official documentation for more information.

chrome.management

The following methods of chrome.management are supported:

  • chrome.management.getAll
  • chrome.management.get
  • chrome.management.getSelf
  • chrome.management.getPermissionWarningsById
  • chrome.management.getPermissionWarningsByManifest

The following events of chrome.management are supported:

  • chrome.management.onEnabled
  • chrome.management.onDisabled

See official documentation for more information.

chrome.runtime

The following properties of chrome.runtime are supported:

  • chrome.runtime.lastError
  • chrome.runtime.id

The following methods of chrome.runtime are supported:

  • chrome.runtime.getBackgroundPage
  • chrome.runtime.getManifest
  • chrome.runtime.getPlatformInfo
  • chrome.runtime.getURL
  • chrome.runtime.connect
  • chrome.runtime.sendMessage
  • chrome.runtime.reload

The following events of chrome.runtime are supported:

  • chrome.runtime.onStartup
  • chrome.runtime.onInstalled
  • chrome.runtime.onSuspend
  • chrome.runtime.onSuspendCanceled
  • chrome.runtime.onConnect
  • chrome.runtime.onMessage

See official documentation for more information.

chrome.scripting

All features of this API are supported.

See official documentation for more information.

chrome.storage

The following methods of chrome.storage are supported:

  • chrome.storage.local
  • chrome.storage.sync (partial support)
    • stored on disk next to chrome.storage.local in a separate storage area and subject to Chrome's sync quotas; data is not synced across devices, matching Chrome with sync disabled.

chrome.storage.managed is not supported.

See official documentation for more information.

chrome.tabs

The following methods of chrome.tabs are supported:

  • chrome.tabs.sendMessage
  • chrome.tabs.reload
  • chrome.tabs.executeScript
  • chrome.tabs.query (partial support)
    • supported properties: url, title, audible, active, muted.
  • chrome.tabs.update (partial support)
    • supported properties: url, muted.

Note

In Chrome, passing -1 as a tab ID signifies the "currently active tab". Since Electron has no such concept, passing -1 as a tab ID is not supported and will raise an error.

See official documentation for more information.

chrome.webRequest

All features of this API are supported.

Note

Electron's webRequest module takes precedence over chrome.webRequest if there are conflicting handlers.

See official documentation for more information.