Web SDKv1.0.0

Kernstra.init()

Initialize the SDK — verifies the license and loads the engine binary. Call before creating any viewer; resolves when the engine is ready.

Idempotent: a second call with the same options gets the same promise (React's StrictMode needs no guard), one with other options rejects with INVALID_ARGUMENT, and a failed call starts over on the next. An empty or missing license means "no license given"; only setLicense('') signs out and forgets the cached token.

The token is verified locally in milliseconds; its status is confirmed with the licensing API once per load. A load that holds a recent good answer never waits; a load without one (the first on a browser, site data cleared, a frame without storage, an answer older than 48 hours, or a paused license) waits for the check, at most 8 seconds. Nothing runs that we did not publish: the engine, the shaping and subsetting binaries and every bundled font are downloaded from the asset store your license names, by digest, verified and cached in the browser.

static methodLifecyclesince 1.0.0

Signature

static init(options?: SDKInitOptions): Promise<void>

Parameters

ParameterTypeDescription
options?SDKInitOptionslicense (your license token), engineUrl, shaperUrl and subsetterUrl (self-hosted copies of the binaries — self-hosting licenses only), workerUrl (the render worker), styleNonce (the page's CSP nonce, carried by every stylesheet the SDK injects) and licensePopup (the "License required" popup in your own words). See Initialization.

Returns

Promise<void> Resolves when the engine is ready.

Throws

  • LICENSE_REQUIRED — no valid license, or not a secure context (the SDK runs only over HTTPS or on localhost; on a plain-HTTP origin it refuses to start with reason insecure-context).
  • FEATURE_NOT_LICENSED — engineUrl, shaperUrl or subsetterUrl given without a self-hosting license.
  • ENGINE_LOAD_FAILED — the binary was not downloaded, not verified, or not started.
  • INVALID_ARGUMENT — a second call with other options, a styleNonce that is not base64 or base64url, or a licensePopup part that is not a string.
  • INVALID_STATE — called outside a browser, where there is no window or document: server rendering.

Example

TypeScript
await Kernstra.init({ license: import.meta.env.KERNSTRA_LICENSE });

More in Kernstra