# Kernstra.onLicenseChange()

```ts
static onLicenseChange(callback: (state: LicenseState) => void): () => void
```

Calls `callback` with each new license state; returns a function that unsubscribes. The same changes arrive as the [`licenseChanged`](https://kernstra.com/docs/web-sdk/api/events#ev-licensechanged) event on `Kernstra.events`. A verdict that takes rights away — revoked, paused, fewer features, the outage grace period run out — is reported at once here but reaches only the **next load** (`init`, `setLicense`, or opening a document): whoever is exporting, printing or filling a form in an open document finishes. Listen here if your app should react sooner.

`Kernstra.destroy()` removes these subscriptions; one made before an `init()` refused for want of a license stays, so it sees the retry.

- Kind: static method
- Since: 1.0.0

| Parameter | Type | Description |
| --- | --- | --- |
| `callback` | `(state: LicenseState) => void` | Called with each new license state. |

Returns `() => void`: A function that unsubscribes.

```ts
const stop = Kernstra.onLicenseChange((state) => {
  if (!state.valid) showBanner('License problem: ' + state.reason);
});
// later
stop();
```

Part of [Kernstra](https://kernstra.com/docs/web-sdk/api/kernstra) in the Kernstra Web SDK 1.0.0 API reference.

Web page: https://kernstra.com/docs/web-sdk/api/kernstra/onlicensechange
