---
source: https://qlik.dev/embed/qlik-embed/customize/qlik-embed-lifecycle-events/
last_updated: 2026-11-30T07:19:53Z
---

# How to react to embed state with lifecycle events

## Overview

`qlik-embed` emits lifecycle events that let your host application react to the embedded UI's
rendering stages. Use them to hide a custom loading skeleton once content appears, enable or
disable your own controls based on embed state, synchronize sheet navigation with your router or
URL, and measure render performance. Without these events you would be forced to rely on timers
or polling.

Lifecycle events report on *render and navigation* state. To react to *data and selection* state
(for example, when a user makes a selection), use the imperative
[refApi](https://qlik.dev/embed/qlik-embed/customize/interact-with-ref-api/) instead.

## Prerequisites

- A working `qlik-embed` instance with authentication configured. See
  [Connect with qlik-embed](https://qlik.dev/embed/qlik-embed/authenticate/connect-qlik-embed/).
- Minimum package versions:

  | Package                      | Version |
  | ---------------------------- | ------- |
  | `@qlik/embed-web-components` | 1.7.0   |
  | `@qlik/embed-react`          | 2.5.0   |
  | `@qlik/embed-svelte`         | 1.1.0   |
  | `@qlik/embed-runtime`        | 1.6.0   |

## Event reference

| Callback         | UIs             | Web component event        | `detail` payload      |
| ---------------- | --------------- | -------------------------- | --------------------- |
| `onReady`        | All             | `qlik-embed:ready`         | *(none)*              |
| `onSheetChanged` | `classic/app`   | `qlik-embed:sheet-changed` | `{ sheetId: string }` |
| `onSheetReady`   | `classic/app`   | `qlik-embed:sheet-ready`   | `{ sheetId: string }` |
| `onRendered`     | `classic/chart` | *(callback only)*          | *(none)*              |

In web components, events are dispatched on the `<qlik-embed>` element and carry their data in
`event.detail`. In React and Svelte, you pass a callback prop that receives the payload as its
first argument. `onRendered` is available only as a callback prop; it has no corresponding DOM
event.

## Steps

### Step 1: React to first render with `onReady`

`onReady` fires once, when the embedded UI finishes its first render. It is available on every UI.
This is the moment to hide a loading skeleton or enable controls that depend on the embed being
visible.

Events are non-bubbling, so attach the listener directly on the `<qlik-embed>` element, not on a
parent container.

```html
<qlik-embed
  id="sheet"
  ui="analytics/sheet"
  app-id="<APP_ID>"
  sheet-id="<SHEET_ID>"
></qlik-embed>
<div id="loader">Loading...</div>
```

```javascript
const embed = document.getElementById("sheet");
const loader = document.getElementById("loader");

embed.addEventListener("qlik-embed:ready", () => {
  loader.hidden = true;
});
```

```tsx
import { useState } from "react";
import { QlikEmbed } from "@qlik/embed-react";

export function Dashboard() {
  const [isLoading, setIsLoading] = useState(true);

  return (
    <>
      {isLoading && <div className="loader">Loading...</div>}
      <QlikEmbed
        ui="analytics/sheet"
        appId="<APP_ID>"
        sheetId="<SHEET_ID>"
        onReady={() => setIsLoading(false)}
        style={{ display: isLoading ? "none" : "contents" }}
      />
    </>
  );
}
```

```svelte
<script lang="ts">
  import QlikEmbed from "@qlik/embed-svelte";
  let isLoading = true;
</script>

{#if isLoading}
  <div class="loader">Loading...</div>
{/if}

<QlikEmbed
  ui="analytics/sheet"
  appId="<APP_ID>"
  sheetId="<SHEET_ID>"
  onReady={() => (isLoading = false)}
  style:display={isLoading ? "none" : "contents"}
/>
```

> **Note:** `onReady` fires once per mount. If you remove the element from the DOM and add it back, a new
> mount occurs and the event fires again.

### Step 2: Track sheet navigation in `classic/app`

`onSheetChanged` fires each time the user navigates to a different sheet, and `onSheetReady` fires
once that sheet has finished rendering. Both carry the new `sheetId`. Use `onSheetChanged` to update
your URL and show a transient loading indicator, and `onSheetReady` to re-enable controls once the
content is visible. These events are emitted only by `classic/app`.

```html
<qlik-embed
  id="classic-app"
  ui="classic/app"
  app-id="<APP_ID>"
  sheet-id="<SHEET_ID>"
></qlik-embed>
```

```javascript
const classicApp = document.getElementById("classic-app");

classicApp.addEventListener("qlik-embed:sheet-changed", (event) => {
  const { sheetId } = event.detail;
  history.pushState({ sheetId }, "", `?sheet=${sheetId}`);
});

classicApp.addEventListener("qlik-embed:sheet-ready", (event) => {
  const { sheetId } = event.detail;
  console.log("Sheet ready:", sheetId);
});
```

If you use TypeScript, cast the event to `CustomEvent` to access `detail` with type safety:

```typescript
classicApp.addEventListener("qlik-embed:sheet-changed", (event: Event) => {
  const { sheetId } = (event as CustomEvent<{ sheetId: string }>).detail;
});
```

```tsx
<QlikEmbed
  ui="classic/app"
  app="<APP_ID>"
  sheet="<SHEET_ID>"
  onSheetChanged={({ sheetId }) => {
    window.history.pushState(null, "", `?sheet=${sheetId}`);
  }}
  onSheetReady={({ sheetId }) => {
    console.log("Sheet ready:", sheetId);
  }}
/>
```

```svelte
<QlikEmbed
  ui="classic/app"
  app="<APP_ID>"
  sheet="<SHEET_ID>"
  onSheetChanged={({ sheetId }) => history.pushState(null, "", `?sheet=${sheetId}`)}
  onSheetReady={({ sheetId }) => console.log("Sheet ready:", sheetId)}
/>
```

### Step 3: Detect chart render with `onRendered`

`onRendered` fires after a `classic/chart` renders or re-renders. It does not fire while the chart
is waiting for an update, for example after a selection. It is a callback prop only: there is no
corresponding DOM event, so it is unavailable when you attach listeners to a web component element.

```tsx
<QlikEmbed
  ui="classic/chart"
  appId="<APP_ID>"
  objectId="<OBJECT_ID>"
  onRendered={() => console.log("Chart rendered")}
/>
```

```svelte
<QlikEmbed
  ui="classic/chart"
  appId="<APP_ID>"
  objectId="<OBJECT_ID>"
  onRendered={() => console.log("Chart rendered")}
/>
```

## Verification

To confirm your listeners are wired correctly, log each event and watch the browser console as the
embed loads and you navigate between sheets. You should see `qlik-embed:ready` fire exactly once on
first render, followed by a `qlik-embed:sheet-changed` and `qlik-embed:sheet-ready` pair each time
you switch sheets in a `classic/app` embed.

> **Events are non-bubbling:** Lifecycle events do not propagate up the DOM. Attach listeners directly to the `<qlik-embed>`
> element. Event delegation on a parent container will not receive them.

> **Other events on the DOM surface:** The four callbacks above are the typed lifecycle events, but some UIs emit additional events on
> the same `qlik-embed:*` DOM surface. For example, `insights/feed-cards` can emit
> `qlik-embed:app-navigate-requested`. See the
> [events reference](https://qlik.dev/embed/qlik-embed/parameters/#events) for the full list of events per UI.
