Skip to content

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.

S extends SiteSchema

ServerClientOptions<S>

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.

F extends string

F | readonly F[]

ServerDecideOptions = {}

Promise<DecideResults<S, F>>

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(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.

S["journeys"]

string

EdgeKitConfigError when baseUrl, apiKey or siteId is missing or empty.