Skip to main content
useToken is the sole client-side token acquisition hook. It GETs your token endpoint (default /api/aiql), stores the JWT, and refreshes it about 30 seconds before expiry.

Import

Usage

Basic

Custom endpoint URL

Handle status

Response shape from your endpoint

Your server should return JSON like:
The hook also accepts a raw embedUrl field and extracts the token query param when present.

API Reference

Parameters

Return value

See Server handlers for the matching one-line backend.