Skip to content

TryYourSize()

Function@tryyoursize/sdk

Creates a client for your publishable key. Every element and call goes through it.

function TryYourSize(publishableKey: string, options: TryYourSizeOptions = {}): TryYourSizeClient
publishableKeystringRequired

Your publishable key (pk_test_… or pk_live_…) from Studio → Developers → API keys. It works only on the origins registered for it. A secret key (sk_…) throws secret_key_in_browser.

optionsTryYourSizeOptionsOptional= {}
Properties
embedOriginstringOptional

Override for development (e.g. http://localhost:5173).

apiOriginstringOptional

Override of the API origin for development (e.g. http://localhost:8000): the A/B holdout config.

localeLocaleOptional

Language of our windows; "auto" follows the browser.

TryYourSizeClient: The client: elements(), recommendation(), recommendationHandle(), experiment() and version.

TryYourSizeError with code secret_key_in_browser or invalid_key. See Web SDK errors.

import { TryYourSize } from "@tryyoursize/sdk";
const tys = TryYourSize("pk_test_…", { locale: "es" }); // windows in Spanish

Was this page helpful?