Setup
Initialize the SDK in your browser extension's background and content scripts
Overview
After configuring your manifest, you need to initialize the SDK in two places:
- Background Service Worker: Manages offscreen documents and verification orchestration
- Content Script Loading: Bridges communication (optional if using static manifest registration)
This guide covers both initialization methods and best practices.
Background Initialization
Basic Setup
Initialize the SDK in your background service worker (background.js or similar):
Idempotent Operation: initializeBackground() is safe to call multiple times. The SDK handles duplicate initialization attempts
gracefully, making it perfect for service worker reactivation scenarios.
What Does Background Initialization Do?
When you call initializeBackground(), the SDK:
- Sets up message listeners for communication between extension components
- Registers offscreen document handlers for proof generation
- Prepares network interception capabilities
- Establishes verification flow orchestration
Content Script Loading
The SDK's content script bridge must be loaded into web pages to enable communication. You have two options: static registration (via manifest) or dynamic registration (via code).
Option 1: Static Registration (Recommended)
This is the simplest approach and is already configured if you followed the Manifest Configuration guide.
Your manifest.json includes:
Advantages:
- ✅ Automatic injection on all pages
- ✅ No additional code required
- ✅ Simpler to maintain
- ✅ Loaded before page scripts
No additional setup needed - the content script is automatically injected.
Option 2: Dynamic Registration
Dynamic registration gives you more control over when and where the content script loads. Requires the "scripting" permission in your manifest.
Add to your manifest.json:
Registration on Installation
Register the content script when your extension is installed:
Registration with Duplicate Check
Prevent duplicate registrations across service worker restarts:
Loading Multiple Content Scripts
If your extension has its own content scripts, load them after the SDK bridge:
In Manifest (Static)
Dynamically (Advanced)
Debugging Setup
Verify Background Initialization
- Open chrome://extensions
- Find your extension and click "service worker"
- Check console for initialization messages:
Verify Content Script Injection
- Navigate to any web page
- Open DevTools (F12)
- Go to the Console tab
- Look for SDK initialization messages or check sources:
Check Registered Scripts
For dynamic registration, verify scripts are registered:
Common Setup Issues
Service Worker Not Starting
Symptoms: Background initialization not running
Solutions:
- Check for syntax errors in background.js
- Verify "background"is correctly defined in manifest
- Look for errors in the service worker console
Content Script Not Injecting
Symptoms: Verification fails, no communication with pages
Solutions:
- Verify content script path matches your public directory
- Check run_atis set to"document_start"
- Ensure host_permissionsincludes target domains
- Reload the extension and refresh test pages
Duplicate Initialization Errors
Symptoms: Console shows multiple initialization messages
Solution: This is usually harmless due to service worker reactivation. The SDK handles duplicate calls safely.
Next Steps
With background and content scripts set up, you're ready to implement verification flows in your extension popup or panel:
 Reclaim Protocol Docs
Reclaim Protocol Docs