Skip to main content
We’ve released a new and improved web extension SDK under @sleek/web-ext-sdk, replacing the legacy @sleek/web-ext-coupon-sdk. This new SDK brings enhanced performance, additional capabilities, and a more extensible foundation for future features. If you’re currently using @sleek/web-ext-coupon-sdk, follow the guide below to migrate to @sleek/web-ext-sdk.

Summary of Key Changes

Feature@sleek/web-ext-coupon-sdk@sleek/web-ext-sdk
Core methodsinitializeSleekSdk, getSdkInstanceinitializeWebExtSdk, getWebExtSdk
Script filesfc.js, f.js, t.jsmf.js, f.js
EventsMainly coupon-focusedCoupon, classification, product, order, affiliate activation detection
PerformanceLegacyMore performant and modular
Type SafetyTypedStronger types, extensible event system
PermissionsRequires alarms permissionalarms permission no longer required

1. Update Your Dependency

Update your .npmrc if not already configured:
@sleek:registry=https://npm.cloudsmith.io/sleek/sleek/
//npm.cloudsmith.io/sleek/sleek/:_authToken={YOUR_TOKEN_HERE}
Replace the legacy SDK with the new one:
pnpm remove @sleek/web-ext-coupon-sdk
pnpm add @sleek/web-ext-sdk

2. Update Static Script Inclusion

Old:
fc.js, f.js, t.js
New:
mf.js, f.js
Copy from:
node_modules/@sleek/web-ext-sdk/dist/
Place them in your built extension root next to manifest.json.

3. Update Permissions

Ensure your manifest includes:
"permissions": ["storage", "tabs", "webRequest", "scripting"]
For MV3:
"host_permissions": ["<all_urls>"]

4. Update Initialization

Old:
import { initializeSleekSdk } from '@sleek/web-ext-coupon-sdk';

initializeSleekSdk(process.env.SLEEK_API_KEY);
New:
import { initializeWebExtSdk } from '@sleek/web-ext-sdk';

await initializeWebExtSdk(process.env.SLEEK_API_KEY);

5. Update Event Handling

Old:
import { getSdkInstance } from '@sleek/web-ext-coupon-sdk';

getSdkInstance().registerEventListener((event, { tabId }) => {
  // handle event
});
New:
import { getWebExtSdk } from '@sleek/web-ext-sdk';

getWebExtSdk().registerEventListener((event, tabDetails) => {
  // handle event
});
If you plan to call getWebExtSdk() immediately after initialization, you must await the initializeWebExtSdk() promise first. The SDK is not available until initialization completes.

6. Update SDK Usage

The new @sleek/web-ext-sdk introduces a more modular and intuitive API design. Instead of global functions, you now operate on a specific tab context using .onTab(tabId) for all tab-related actions. Here’s a mapping of commonly used methods to help you migrate:
Legacy @sleek/web-ext-coupon-sdkNew @sleek/web-ext-sdk
getSdkInstance().fillCouponsOnTab(tabId, options?: FillCouponsOnTabOptions)getWebExtSdk().onTab(tabId).startCouponAutoApply(codes)
getSdkInstance().cancelCouponsOnTab(tabId)getWebExtSdk().onTab(tabId).stopCouponAutoApply()
getSdkInstance().classifyPageOnTab(tabId)getWebExtSdk().onTab(tabId).classifyPage()
getSdkInstance().extractProductsOnTab(tabId, options?: ExtractProductsOnTabOptions)getWebExtSdk().onTab(tabId).extractProducts(options?: ExtractProductsOptions)
getSdkInstance().extractOrderOnTab(tabId)getWebExtSdk().onTab(tabId).extractOrder()

Before (Legacy SDK)

import { getSdkInstance } from '@sleek/web-ext-coupon-sdk';

getSdkInstance().fillCouponsOnTab(tabId);

After (New SDK)

import { getWebExtSdk } from '@sleek/web-ext-sdk';

getWebExtSdk().onTab(tabId).startCouponAutoApply(['CODE123']);

New Capabilities

Updated TypeDoc

Explore new capabilities:
Need help? Contact [email protected] for questions or migration assistance.