Svelte Guide

Install

The Svelte SDK is available via npm:

npm install resubscribe-svelte-sdk

Setup

Import Resubscribe.

import Resubscribe from 'resubscribe-svelte-sdk';

Add the component to your tree. It will not render anything until you trigger it.

<div>
    ...
    <Resubscribe.Component />
</div>

When you would like to open up Resubscribe, call openWithConsent, replacing the placeholder values with your own values.

Resubscribe.openWithConsent({
  slug: '{organization-slug}',
  apiKey: '{api-key}',
  aiType: '{ai-type}',
  userId: '{uid}',
  userEmail: '{optionalEmail}',
  colors: {
    primary: 'blue',
    background: '#eee',
    text: '#333',
  }
});

The value of userId MUST be unique. If you do not have a unique user id at the point you want to make this call, we recommend generating a random value prefixed with 'anonymous-' for every user

Configuration

You can pass the following parameters into openWithConsent.

Headless

Resubscribe additionally supports a headless mode if you would like more control over the consent modal. This is not recommended.

Last updated