JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 46
  • Score
    100M100P100Q64829F
  • License UNLICENSED

Encore SDK for web applications - display targeted offers and manage user entitlements

Package Exports

  • @encorekit/web-sdk
  • @encorekit/web-sdk/react

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-sdk

Or 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);
  console.log('Offer granted:', result.entitlement);
  // Handle user completed Encore offer
} else {
  console.log('User declined:', result.reason);
}

// Check entitlement on YOUR server (not client-side)
// See: https://docs.encorekit.com/server-side-validation

Browser Support

  • Chrome/Edge (last 2 versions)
  • Firefox (last 2 versions)
  • Safari (last 2 versions)
  • iOS Safari 15+

iOS HTML Tag Integration

The simplest possible integration - just build a URL and open it in a WKWebView. No SDK, no dependencies, no complexity.

Quick Start (3 Lines of Code!)

// 1. Build URL
let url = EncoreURL.build(apiKey: "your_key", userId: "user_123")!

// 2. Create WebView and load it
let webView = WKWebView(frame: view.bounds)
view.addSubview(webView)
webView.load(URLRequest(url: url))

// That's it! 🎉

Complete Example

import UIKit
import WebKit

// Copy EncoreURLBuilder.swift to your project (one file!)
func showEncoreOffer() {
    let url = EncoreURL.build(
        apiKey: "pk_live_...",
        userId: currentUser.id,
        attributes: [
            "email": currentUser.email,
            "subscriptionTier": currentUser.tier
        ]
    )!
    
    let webView = WKWebView(frame: view.bounds)
    webView.backgroundColor = .clear
    view.addSubview(webView)
    webView.load(URLRequest(url: url))
}

SwiftUI Version

import SwiftUI

struct MyView: View {
    var body: some View {
        EncoreWebView(
            apiKey: "pk_live_...",
            userId: currentUser.id
        )
    }
}

What You Get

  • Zero dependencies - Just one Swift file
  • 3 lines of code - Build URL, create WebView, load
  • Auto-initialization - Embed handles everything
  • Full features - Offers, entitlements, tracking
  • Works everywhere - UIKit, SwiftUI, any iOS app

Documentation

Advanced: With Callbacks

Need callbacks when offers complete? Use the full bridge integration.

When to Use

Feature Simple (URL) Native iOS SDK
Integration 3 lines ~50 lines
Dependencies None Requires SPM
Callbacks No Yes
Works?

Use simple integration for 99% of cases. Only need the full bridge if you require granular callbacks.

Documentation