Skip to content

For any project with a bundler: install the packages, set the config in a module that runs first, and import the components you use.

  1. A package manager (npm, yarn, pnpm, or bun) and a bundler.
  2. A merchant account on the Frak business dashboard with your domain registered. The main domain is registered at sign-up; add subdomains under Allowed Domains.

If you have not done that yet, start with the Get started guide.

PackageWhat it gives you
@frak-labs/componentsThe <frak-*> web components. Importing one registers it and boots the SDK.
@frak-labs/core-sdkThe client and the actions, for anything you drive yourself.
Terminal window
npm install @frak-labs/components @frak-labs/core-sdk

Put the config in its own module so it runs before anything imports a component:

frak-setup.ts
import type { FrakWalletSdkConfig } from "@frak-labs/core-sdk";
declare global {
interface Window {
FrakSetup: { config?: FrakWalletSdkConfig };
}
}
window.FrakSetup = {
config: {
metadata: {
name: "Your Store",
currency: "eur",
},
},
};

Every field is listed on the FrakSetup reference and in Configuration.

Import your config module first, then each component you use. The imports are side-effectful: they register the custom element and boot the SDK from window.FrakSetup.config.

main.ts
import "./frak-setup";
import "@frak-labs/components/banner";
import "@frak-labs/components/buttonShare";
import "@frak-labs/components/postPurchase";

Available subpaths: banner, buttonShare, buttonWallet, openInApp, postPurchase. There is no root import, so import the subpath you need.

Then use the elements in your markup:

<frak-banner></frak-banner>
<frak-button-share classname="button"></frak-button-share>

Actions live in @frak-labs/core-sdk/actions. All of them except trackPurchaseStatus take the client as their first argument, and the client is published on window.FrakSetup.client once the SDK is ready:

import { displayModal, watchWalletStatus } from "@frak-labs/core-sdk/actions";
import type { FrakClient } from "@frak-labs/core-sdk";
function waitForClient(): Promise<FrakClient> {
if (window.FrakSetup?.client) return Promise.resolve(window.FrakSetup.client);
return new Promise((resolve) => {
window.addEventListener(
"frak:client",
() => resolve(window.FrakSetup.client as FrakClient),
{ once: true }
);
});
}
const client = await waitForClient();
await watchWalletStatus(client, (status) => {
console.log(status.key === "connected" ? status.wallet : "not connected");
});
await displayModal(client, {
steps: {
login: {},
final: { action: { key: "sharing" } },
},
});
import { trackPurchaseStatus } from "@frak-labs/core-sdk/actions";
await trackPurchaseStatus({
customerId: "cust_123",
orderId: "order_456",
token: "a-unique-order-token",
});

Rewards are only released once your backend confirms the order with a signed webhook. See Validate purchases from your backend.

ActionPurpose
watchWalletStatusCurrent wallet status, plus every change
displayModalOpen a modal built from steps (login, final, and more)
displaySharingPageOpen the sharing page directly
displayEmbeddedWalletOpen the embedded wallet view
sendInteractionSend an interaction, fire and forget
trackPurchaseStatusRegister an order so a confirmed sale can pay a reward
referralInteraction, processReferral, setupReferralHandle an inbound referral
getMerchantInformationYour merchant data as resolved by the backend
getUserReferralStatus, getMergeTokenReferral state and wallet merge token
openSso, prepareSso, prepareSsoUrlSingle sign-on flows
siweAuthenticateSign-In with Ethereum
sendTransactionAsk the wallet to send a transaction
modalBuilderFluent builder for modal steps

Full signatures live in the generated SDK reference.

@frak-labs/core-sdk also exposes /rewards and /identity subpaths, and /bundle (index plus actions in one import) for CDN-style consumption.

If you do not use the components package, create the client by hand. Call setupClient once and reuse the promise: each call recreates the listener iframe.

frak-client.ts
import { setupClient, type FrakWalletSdkConfig } from "@frak-labs/core-sdk";
const config: FrakWalletSdkConfig = {
metadata: { name: "Your Store" },
};
let clientPromise: ReturnType<typeof setupClient> | undefined;
export function getFrakClient() {
clientPromise ??= setupClient({ config });
return clientPromise;
}