Skip to main content
The SDK is framework-agnostic — in Svelte you call it directly. Configure once in the root component’s onMount, then present offers from event handlers.

Install

npm install @encorekit/web-sdk

Configure on mount

<!-- App.svelte -->
<script lang="ts">
  import { onMount } from 'svelte';
  import Encore from '@encorekit/web-sdk';

  onMount(() => {
    Encore.configure({ apiKey: import.meta.env.VITE_ENCORE_API_KEY });
  });
</script>
configure() honors only its first successful call — full options in the configure() reference.

Identify and present offers

<script lang="ts">
  import Encore from '@encorekit/web-sdk';

  // After login:
  Encore.identify(user.id); // replaces the auto-generated anonymous UUID

  async function onCancelClicked() {
    const result = await Encore.placement('cancel_flow').show(); // never rejects
    if (result.status !== 'claimed') {
      proceedWithCancellation(); // 'dismissed' or 'unavailable' — continue your flow
    }
  }
</script>

<button on:click={onCancelClicked}>Cancel subscription</button>

Next steps