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)
window, and document.
Manifest V3 (Current)
- Can be terminated at any time by the browser
- No access to DOM,
window, ordocument - Must use message passing for all communication
- Automatically restarted when needed
Architecture Implications
In Manifest V2, this worked:browser-api.ts:434:
Action API Changes
Manifest V2
chrome.browserAction
Manifest V3
chrome.action
The BrowserApi handles this automatically:
Permissions Changes
Host Permissions
Manifest V3 separates host permissions from regular permissions. Manifest V2:New Permissions
Offscreen Permission:Content Security Policy
Manifest V2:Web Request API Changes
Manifest V3 deprecates blockingwebRequest in favor of declarativeNetRequest.
Manifest V2:
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
❌ Wrong - Lost on termination:Keeping Service Worker Alive
Use alarms for periodic tasks:Migration Strategies
1. Replace Background Page Access
Before (V2):2. Use Offscreen Documents for DOM
Service workers cannot access DOM. Use offscreen documents:3. Update Script Injection
Before (V2):4. Handle Service Worker Termination
Design services to be stateless or restore state quickly:Building for Different Manifest Versions
Chrome/Edge (V3 Only)
Firefox (V2 or V3)
Safari (V2 or V3)
Testing Manifest V3
Test service worker termination resilience:1
Build Extension
2
Load in Chrome
- Navigate to
chrome://extensions/ - Enable Developer mode
- Load unpacked extension from
build/
3
Open Service Worker DevTools
- Click “service worker” link in extension card
- DevTools opens for background service worker
4
Test Termination
- Click “Stop” in service worker DevTools
- Interact with extension (open popup, autofill)
- Service worker should restart and function correctly
Common Migration Issues
Issue: Background Page Returns Null
Symptom:Issue: DOM Not Available
Symptom:Issue: State Lost After Inactivity
Symptom: Global variables reset to initial values after 30 seconds. Solution: Store state inchrome.storage:
Resources
Next Steps
- Architecture - Understanding the extension architecture
- Building - Build commands for different browsers