Package Exports
- @encorekit/web-sdk
Readme
Encore Web SDK
A JavaScript/TypeScript SDK that enables web applications to display targeted offers to users, granting them provisional access to premium features when they complete advertiser offers.
Features
- 🎯 Targeted Offer Presentation - Display offers at critical moments (cancellation flows, paywalls, onboarding)
- 🔐 Entitlement Management - Two-tier system (provisional + verified) for instant UX and reliable billing
- 📱 Framework Agnostic - Works with React, Vue, Angular, Svelte, vanilla JavaScript, or any web framework
- 🎨 Responsive UI - Beautiful, accessible modal interface that works on desktop and mobile
- 📦 Lightweight - < 50KB gzipped bundle size
- 🔌 Offline Support - Queues signals and syncs when connectivity restored
- ♿ Accessible - WCAG 2.1 Level AA compliant
Installation
npm install @encorekit/web-sdkOr via CDN:
<script src="https://encorekit.com/encore.min.js"></script>Quick Start
import Encore from '@encorekit/web-sdk';
// Configure the SDK
Encore.configure({
apiKey: 'your-api-key-here',
userId: 'your-user-uuid',
environment: 'production'
});
// Identify the user after login (optional)
Encore.identify('user-123', {
email: 'user@example.com',
subscriptionTier: 'free'
});
// Present an offer
const result = await Encore.presentOffer();
if (result.granted) {
console.log('User granted entitlement:', result.entitlement);
// Notify your backend to check entitlement status
await fetch('/api/encore-callback', {
method: 'POST',
body: JSON.stringify({
userId: Encore.getCurrentUserId(),
entitlement: result.entitlement
})
});
} else {
console.log('User declined:', result.reason);
}
// Check entitlement on YOUR server (not client-side)
// See: https://docs.encorekit.com/server-side-validationBrowser Support
- Chrome/Edge (last 2 versions)
- Firefox (last 2 versions)
- Safari (last 2 versions)
- iOS Safari 15+