Auth Hooks
useAuthenticatedApi
The primary hook for making authenticated API calls. It automatically injects the Clerk JWT token into request headers.
const api = useAuthenticatedApi();
// All requests include Authorization: Bearer <jwt>
const response = await api.get('/api/browser/tests');
Three-Tier Auth Model
- Clerk (global) — All web routes require Clerk authentication
- Analytics —
AnalyticsAuthProvidercontext redirects to setup if ES is unconfigured - Agent admin — Clerk JWT required; agent device endpoints use agent API key
AnalyticsAuthProvider
Wraps Analytics pages and redirects to /analytics/setup if Elasticsearch is not configured:
<AnalyticsAuthProvider>
<AnalyticsDashboard />
</AnalyticsAuthProvider>