@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_KEYandAIQL_WORKSPACE_IDon 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 Router —app/api/aiql/route.ts:
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.
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.