BrowserClientOptions
BrowserClientOptions<
S> =object
Options for createClient.
S is one site’s schema, indexed out of your generated decision types:
createClient<EdgeKitDecisions['site_example']>({ siteId: 'site_example' }).
Index the site; do not pass the whole EdgeKitDecisions type. TypeScript has
no partial type-argument inference, so createClient<EdgeKitDecisions> loses
the 'site_example' literal and keeps only the features every site runs, which is
often none. With the site as the type argument, calling a feature on a site
that does not run it is a compile error.
Type Parameters
Section titled “Type Parameters”S extends SiteSchema
Properties
Section titled “Properties”baseUrl?
Section titled “baseUrl?”
optionalbaseUrl?:string
Absolute URL of your tenant host, for a page that cannot proxy
/edgekit/*. Only its origin is used.
Requests through an absolute baseUrl carry a session only when the
user signed in through that host and it shares the page’s domain
(edgekit.example.com for www.example.com), or the organization’s
cookie domain covers both hosts. By default the session cookie is
host-only and SameSite=Lax: a session started on the page’s own host is
not sent to the tenant host, and a tenant host on another domain never
gets one. Without a session decide still answers 200, as for an
anonymous device, with no error; calls that need a session are refused.
Leave baseUrl unset to use the relative /edgekit/* path on your own
domain, which always identifies the user.
castle?
Section titled “castle?”
optionalcastle?:CastleInstance
Your configured castle.js instance, for the castle.* facts and the
Castle checks at sign-in. When given, the client waits for a fresh Castle
request token before each decide, both sign-in sends, the code sign-in,
each session read (the session store’s too) and an email change request,
and sends it with the request. If castle.js fails to mint one, the request
goes without it. Without castle, no request changes.
experiences?
Section titled “experiences?”
optionalexperiences?:boolean
Show the experience each decided outcome carries: the module the site set
for that outcome, framed by EdgeKit as a modal, banner, slide-in or inline
block, with the outcome’s value. A feature’s next decide replaces it,
or closes it when that answer carries none. One modal shows at a time, the
rest in the order decide was called. Default false.
The frame loads only when a decision carries an experience, so a page
with none pays nothing. The module loads from your own origin’s
/edgekit/x/, whatever baseUrl says, so script-src 'self' allows it.
Nothing about an experience can make decide throw or reject.
onExperienceDismiss?
Section titled “onExperienceDismiss?”
optionalonExperienceDismiss?:ShowExperiencesOptions["onDismiss"]
Told when the user closes an experience, or when one is not shown because
they closed it before (remembered), so the page can draw its own
fallback, such as an inline outcome in place of a closed paywall modal.
onExperienceError?
Section titled “onExperienceError?”
optionalonExperienceError?:ShowExperiencesOptions["onError"]
Told whenever an experience cannot show (its module fails to load, its
mount throws, it has no anchor), so the page can draw its own fallback.
siteId
Section titled “siteId”siteId:
S["id"]
The site this client serves. Must equal S['id']. Create one client per site.
timeoutMs?
Section titled “timeoutMs?”
optionaltimeoutMs?:number
How long decide waits, in milliseconds, before its features answer
unavailable. Default 2000. No other call has a timeout; pass a signal
to cancel one.
tracker?
Section titled “tracker?”
optionaltracker?:ExperienceTracker
Where EdgeKit’s own events go. Every decide sends one
experiment_exposure for each of EdgeKit’s experiments the decision
read, except a preview. An experience sends experience_view,
experience_click, experience_dismiss and experience_error. Each is
a billed event. Pass the tracker @edgekitcloud/analytics-browser
creates; any object with the same trackSelfDescribingEvent fits.
Without one, nothing is sent. A tracker that throws never reaches
decide.