Skip to main content
Manifest V3 is the latest version of the browser extension platform, bringing significant architectural changes focused on security, privacy, and performance.

What is Manifest V3?

Manifest V3 is a major update to the browser extension platform that fundamentally changes how extensions work:
  • Service Workers replace persistent background pages
  • Enhanced security with stricter content security policies
  • Improved privacy with declarative APIs
  • Better performance through resource management

Browser Support

Chrome and Edge require Manifest V3 as of 2024. Firefox and Safari still support Manifest V2 but are transitioning to V3.

Key Differences from Manifest V2

Background Pages → Service Workers

The most significant change is the replacement of persistent background pages with service workers.

Manifest V2 (Legacy)

Background page runs continuously and has access to DOM, window, and document.

Manifest V3 (Current)

Service worker:
  • Can be terminated at any time by the browser
  • No access to DOM, window, or document
  • Must use message passing for all communication
  • Automatically restarted when needed

Architecture Implications

Critical: Service workers can be terminated anytime. Do not assume the background context persists indefinitely. Use message passing for all communication and store state in chrome.storage.
In Manifest V2, this worked:
In Manifest V3, use message passing:
From browser-api.ts:434:

Action API Changes

Manifest V2

API: chrome.browserAction

Manifest V3

API: chrome.action The BrowserApi handles this automatically:

Permissions Changes

Host Permissions

Manifest V3 separates host permissions from regular permissions. Manifest V2:
Manifest V3:
Host permissions are now requested separately and can be optional.

New Permissions

Offscreen Permission:
Used for clipboard operations and other DOM-dependent tasks in service workers. Scripting Permission:

Content Security Policy

Manifest V2:
Manifest V3:
CSP is now an object with separate policies for extension pages and sandboxed pages.

Web Request API Changes

Manifest V3 deprecates blocking webRequest in favor of declarativeNetRequest. Manifest V2:
Manifest V3:
Bitwarden uses webRequestAuthProvider for HTTP Basic Auth interception, which is still allowed in MV3.

Service Worker Lifecycle

Startup and Termination

Service workers follow an event-driven lifecycle:

State Persistence

Do not store state in global variables. Service workers can be terminated, losing all in-memory state. Use chrome.storage for persistence.
❌ Wrong - Lost on termination:
✅ Correct - Persisted in storage:

Keeping Service Worker Alive

Use alarms for periodic tasks:

Migration Strategies

1. Replace Background Page Access

Before (V2):
After (V3):

2. Use Offscreen Documents for DOM

Service workers cannot access DOM. Use offscreen documents:

3. Update Script Injection

Before (V2):
After (V3):
BrowserApi handles this automatically:

4. Handle Service Worker Termination

Design services to be stateless or restore state quickly:

Building for Different Manifest Versions

Chrome/Edge (V3 Only)

These browsers only support Manifest V3.

Firefox (V2 or V3)

Safari (V2 or V3)

Testing Manifest V3

Test service worker termination resilience:
1

Build Extension

2

Load in Chrome

  1. Navigate to chrome://extensions/
  2. Enable Developer mode
  3. Load unpacked extension from build/
3

Open Service Worker DevTools

  1. Click “service worker” link in extension card
  2. DevTools opens for background service worker
4

Test Termination

  1. Click “Stop” in service worker DevTools
  2. Interact with extension (open popup, autofill)
  3. Service worker should restart and function correctly

Common Migration Issues

Issue: Background Page Returns Null

Symptom:
Solution: Use message passing instead:

Issue: DOM Not Available

Symptom:
Solution: Use offscreen documents or move DOM operations to content scripts:

Issue: State Lost After Inactivity

Symptom: Global variables reset to initial values after 30 seconds. Solution: Store state in chrome.storage:

Resources

Next Steps

  • Architecture - Understanding the extension architecture
  • Building - Build commands for different browsers