Skip to main content
@aiql.io/react embeds AiQL Observatory tools in your product via iframe. Your API key stays on the server. The browser only receives a short-lived workspace-scoped embed token.

Prerequisites

  • React 18+
  • An AiQL API key and workspace ID (set as AIQL_API_KEY and AIQL_WORKSPACE_ID on your server)
  • A Next.js App Router app, or any backend that can expose a token endpoint

Try it live

Use the playground below like the API reference: leave fields empty for the shared demo, or enter your own API key and IDs, then click Preview.

Install

Mint an embed token

Create a server route that mints a workspace-scoped token. The browser never sees your API key. Next.js App Routerapp/api/aiql/route.ts:
Express:
See Server handlers for options and other frameworks.

Fetch the token and render

useToken() fetches from /api/aiql and refreshes before expiry. Wrap your components in AiqlProvider, then render one or more embeds.
You can mint the token some other way and pass it to AiqlProvider without using useToken.

Choose a component

Environment variables

Generate an API key in the Dashboard.
Embed tokens are workspace-scoped. /embed/* routes allow framing from any origin (frame-ancestors *). Access is still gated by the embed JWT. Never expose AIQL_API_KEY to the browser.

Next step

Explore the full React SDK reference: overview, hooks, and server.