Signature
Parameters
Configuration object for the SDK
Your public API key from the Encore Dashboard. This key identifies your app and is safe to use in client-side code.
Unique identifier for the user. This should persist across sessions and be set before user authentication.Best Practices:
- Generate an anonymous ID on first visit and store in localStorage
- Use opaque identifiers (not email or sensitive data)
- Keep consistent across sessions for accurate tracking
- Can be different from the ID used in
identify()
API environment to use. Options:
'production' or 'development'.production:https://svc.joinyaw.com/product/encore/v1(default)development:http://localhost:8080/encore/v1(for local testing)
Debug logging level. Options:
'none' or 'debug'.none: No debug logs (recommended for production)debug: Verbose logging for development
Customize the text displayed in the offer modal. All fields are optional.
Return Value
Type:void
The method doesn’t return a value. It configures the SDK for subsequent use.
Examples
Basic Configuration
Full Configuration
With Environment Variables
- Vite (Vue/Svelte)
- React (CRA)
- Angular
Framework Integration
- React
- Vue
- Angular
- Next.js
- Svelte
- Vanilla JS
App.tsx
UI Customization
Customize all text in the offer modal:Best Practices
1. Generate Persistent User IDs
Always generate and persist user IDs in localStorage:2. Configure Early
Callconfigure() as early as possible in your app lifecycle:
3. Use Environment Variables
Never hardcode API keys:4. Enable Debug Logging in Development
5. Configure Once
Don’t callconfigure() multiple times:
6. User ID vs Identity
TheuserId in configure is for tracking. Use identify() for personalization:
Related Methods
- identify() - Associate user with attributes after authentication
- getCurrentUserId() - Get the current userId
- getVersion() - Get SDK version
- setLogLevel() - Change log level after initialization
Utility Methods
getCurrentUserId()
Get the user ID that was provided during configuration:getVersion()
Get the current SDK version:setLogLevel()
Change the log level after initialization:Troubleshooting
Error: userId is required
Error: userId is required
Symptom: SDK throws error about missing userId parameterSolution:
Add the See Migration from v0.1.0 for details.
userId parameter to your configuration:Configuration warnings
Configuration warnings
Symptom: Warning about duplicate configuration callsSolution:
configure()should only be called once- Subsequent calls are ignored
- First configuration is used
- If you need to reconfigure, reload the page
API key errors
API key errors
Symptom: Unauthorized or API errorsSolutions:
- Verify your API key is correct in the Dashboard
- Ensure you’re using the public API key (starts with
pk_) - Check that your API key hasn’t been revoked
- Verify the package name is
@encorekit/web-sdk - Contact admin@encorekit.com if issues persist
TypeScript errors
TypeScript errors
Symptom: Type errors in configurationSolution:
- Ensure
@encorekit/web-sdkis installed - TypeScript types are included automatically
- Use proper type imports if needed:
Vanilla JS: Encore.configure is not a function
Vanilla JS: Encore.configure is not a function
Symptom: In vanilla JS, getting “Encore.configure is not a function”Solution:
Use the UMD export pattern:
Next Steps
After configuration, continue with:- identify() - Associate users with attributes
- presentOffer() - Display targeted offers
- Framework Integration - Complete framework examples