The @sleek/sdk package provides the foundational JavaScript SDK for Sleek, supporting multiple bundling formats (IIFE, ESM, CJS). You can use it directly in web pages via script injection or install it via a package manager in modern frontend setups. This guide walks you through installation, setup, and core usage of the SDK.
Before you start, ensure that you have your Sleek credentials on hand. Contact support if you need help with your credentials.

Installation

If you’re planning to use the SDK via script injection (IIFE), you do not need to install it via a package manager. Just follow the IIFE Usage section.

Install via NPM (CJS / ESM)

The @sleek/sdk package is hosted on Sleek’s private package repository.

Configure .npmrc

@sleek:registry=https://npm.cloudsmith.io/sleek/sleek/
//npm.cloudsmith.io/sleek/sleek/:_authToken={YOUR_TOKEN_HERE}
Replace {YOUR_TOKEN_HERE} with your SDK access token.

Add to your project

# Using npm
npm install @sleek/sdk

# Using pnpm
pnpm add @sleek/sdk

IIFE Usage

If you’re injecting the SDK into pages (e.g., via script tags), you can use the IIFE bundle directly.

Download SDK package

curl -L "https://dl.cloudsmith.io/{YOUR_TOKEN_HERE}/sleek/sleek/npm/sleek/sdk/1.0.0/sleek-sdk-1.0.0.tgz" | tar -xzvf -
This will extract the SDK files locally. You will need the following files:
  • sdk.iife.js: The main SDK file
  • f.js: A supporting script required for the SDK to function properly in-page

Inject into the Page

Make sure these files are injected into the page before any other scripts, ideally at the top of the <head>:
<script src="f.js"></script>
<script src="sdk.iife.js"></script>
<script>
  sleek.initializeSdk("YOUR_PUBLIC_API_KEY_HERE", {}, [
    (event) => {
      console.log("SDK event:", event);
    }
  ]);
  // Use SDK
  sleek.getSdk().startCouponAutoApply(["SAVE10"]);
</script>
The sleek object will be available on globalThis.

Initialization

Call initializeSdk with your public Sleek API key to initialize the SDK:
import { initializeSdk } from "@sleek/sdk";

initializeSdk("YOUR_PUBLIC_API_KEY_HERE", {
  // Optional configuration options
}, [(event) => {console.log("Received event", event);}]);
Once initialized, retrieve the SDK instance:
import { getSdk } from "@sleek/sdk";

getSdk().startCouponAutoApply(["SAVE10"]);

Core Features

The @sleek/sdk provides a tab/page-agnostic interface that powers: Refer to the TypeDoc reference for full API documentation.

Events

To listen for SDK events, pass an array of listener functions to initializeSdk as the third argument:
initializeSdk("YOUR_PUBLIC_API_KEY_HERE", {}, [
  (event) => {
    console.log("SDK Event:", event);
  }
]);
Each listener receives an event of type SdkEvent.

File Formats

FormatFileUse Case
IIFEsdk.iife.jsScript tag or runtime script injection
ESMsdk.esm.jsModern bundlers (Vite, Webpack, etc.)
CJSsdk.cjs.jsNode or CommonJS environments

What’s Next

Once you’ve installed and initialized the SDK, you can extend your integration with:
Need help? Contact our support team.