createServerClient
createServerClient<
S>(options):object
Creates a decision client for one site, from a server: Node, Cloudflare
Workers or Bun. It uses the global fetch and has no dependencies.
Type Parameters
Section titled “Type Parameters”S extends SiteSchema
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”decide()
Section titled “decide()”decide<
F>(features,request?):Promise<DecideResults<S,F>>
Asks the decision engine about one feature, or up to 32 in one call.
Resolves with a result for every requested name: decided, unknown
(the deployment has no such feature) or unavailable (a timeout, a
network error, an unexpected response body, or a status such as 422,
429 or 5xx). A decision failure never throws, and the client never
retries: the retry policy is yours.
Type Parameters
Section titled “Type Parameters”F extends string
Parameters
Section titled “Parameters”features
Section titled “features”F | readonly F[]
request?
Section titled “request?”ServerDecideOptions = {}
Returns
Section titled “Returns”Promise<DecideResults<S, F>>
Throws
Section titled “Throws”EdgeKitConfigError on a caller error that no retry
fixes: no feature names, more than 32, or a 400, 401, 403 or
404 from the route.
forwardUrl()
Section titled “forwardUrl()”forwardUrl(
feature):string
Builds the URL for a journey feature, for a Response.redirect or an
<a href>; never fetch it. GET /v1/decide/forward answers 302 to
a destination the batch response withholds, so fetching the URL fetches
the destination page. Sends no request. The route takes no API key and
refuses an asserted user, so the URL carries the site and nothing from
asUser: the user comes from the browser’s own access cookie.
Parameters
Section titled “Parameters”feature
Section titled “feature”S["journeys"]
Returns
Section titled “Returns”string
Throws
Section titled “Throws”EdgeKitConfigError when baseUrl, apiKey or siteId is
missing or empty.