Appearance
Configuration
Learn how to configure the ExtensionLogin SDK for your needs.
Initialization Options
Pass configuration options when initializing:
javascript
import ExtensionLogin from 'extensionlogin';
ExtensionLogin.init({
// Required
apiKey: 'el_live_xxxxxxxxxxxxxx',
// Optional
debug: false,
autoIdentify: false,
storage: 'local',
apiUrl: 'https://api.extensionlogin.com'
});Options Reference
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | Required | Your ExtensionLogin API key |
debug | boolean | false | Enable debug logging to console |
autoIdentify | boolean | false | Auto-identify users from storage on init |
storage | 'local' | 'sync' | 'none' | 'local' | Chrome storage type for user data |
apiUrl | string | 'https://api.extensionlogin.com' | API endpoint (for self-hosted) |
API Key Types
ExtensionLogin uses different API key prefixes for different environments:
| Prefix | Environment | Purpose |
|---|---|---|
el_live_ | Production | Live production traffic |
el_test_ | Testing | Development and testing |
Use Test Keys in Development
Use el_test_ keys during development. They won't count against your user limits and make it easy to identify test data.
Storage Options
Local Storage (Default)
User data is stored in chrome.storage.local:
javascript
ExtensionLogin.init({
apiKey: 'el_live_xxx',
storage: 'local'
});- Persists across browser sessions
- Not synced between devices
- Larger storage limits (~5MB)
Sync Storage
User data is synced across devices:
javascript
ExtensionLogin.init({
apiKey: 'el_live_xxx',
storage: 'sync'
});- Syncs across user's Chrome devices
- Smaller limits (~100KB)
- Requires user to be signed into Chrome
No Storage
Disable local storage entirely:
javascript
ExtensionLogin.init({
apiKey: 'el_live_xxx',
storage: 'none'
});- User data not persisted locally
- Must re-identify on each session
- Useful for privacy-sensitive applications
Auto-Identify
Automatically restore user session on initialization:
javascript
ExtensionLogin.init({
apiKey: 'el_live_xxx',
autoIdentify: true
});
// Later, check if user is already identified
const user = ExtensionLogin.getUser();
if (user) {
console.log('Welcome back,', user.email);
}Debug Mode
Enable detailed logging for development:
javascript
ExtensionLogin.init({
apiKey: 'el_live_xxx',
debug: true
});
// Console will show:
// [ExtensionLogin] Initialized with API key: el_live_xxx...
// [ExtensionLogin] Making request to /sdk/identify
// [ExtensionLogin] Response: { success: true, ... }Environment-Based Configuration
Use different configurations for development and production:
javascript
const isDev = chrome.runtime.getManifest().version === '0.0.0';
ExtensionLogin.init({
apiKey: isDev ? 'el_test_xxx' : 'el_live_xxx',
debug: isDev,
storage: isDev ? 'local' : 'sync'
});Or use build-time environment variables:
javascript
ExtensionLogin.init({
apiKey: process.env.EXTENSIONLOGIN_API_KEY,
debug: process.env.NODE_ENV === 'development'
});Multiple Extensions
If you have multiple extensions sharing an account, create separate applications in the dashboard and use different API keys:
javascript
// Extension A
ExtensionLogin.init({ apiKey: 'el_live_extension_a_key' });
// Extension B
ExtensionLogin.init({ apiKey: 'el_live_extension_b_key' });Each extension's users will be tracked separately in the dashboard.
Rate Limits
ExtensionLogin enforces rate limits to ensure fair usage:
| Plan | Requests/minute | Requests/day |
|---|---|---|
| Free | 60 | 1,000 |
| Pro | 300 | 10,000 |
| Enterprise | Unlimited | Unlimited |
When rate limited, the SDK will:
- Return an error response with
code: 'RATE_LIMITED' - Include
retryAfterindicating when to retry
javascript
const result = await ExtensionLogin.identify({ email: '[email protected]' });
if (!result.success && result.error?.code === 'RATE_LIMITED') {
console.log('Rate limited. Retry after:', result.error.retryAfter);
}Next Steps
- Authentication Flow - Understand the auth process
- User Identification - Deep dive into identify()