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.
Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
| options? | SDKInitOptions | license (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 onlocalhost; on a plain-HTTP origin it refuses to start with reasoninsecure-context).FEATURE_NOT_LICENSED—engineUrl,shaperUrlorsubsetterUrlgiven 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, astyleNoncethat is not base64 or base64url, or alicensePopuppart that is not a string.INVALID_STATE— called outside a browser, where there is nowindowordocument: server rendering.
Example
await Kernstra.init({ license: import.meta.env.KERNSTRA_LICENSE });