Skip to main content
The React SDK never sends your API key to the browser. Your server mints a short-lived embed token by calling app.aiql.io/api/embed/tokens, then the client fetches that token from your own route (default /api/aiql). @aiql.io/react/server is a React-free entry point safe to import in Next.js route handlers, Express, or any Node runtime.

Security model

  1. Store AIQL_API_KEY and AIQL_WORKSPACE_ID as server env vars.
  2. Expose a same-origin endpoint (for example GET /api/aiql).
  3. The handler calls AiQL with Authorization: Bearer <API_KEY> and returns { token, expiresAt, expiresIn } to the browser.
  4. useToken reads that response and passes the JWT into AiqlProvider.

Environment variables

Import

Next steps

See Handlers for one-line Next.js and Express setup, plus the core mintWorkspaceToken API.