API keys

A person makes a key for the brand's own API, for a script of theirs, and the API checks it with Synq on every request: here, the demo's own API.

Built on @synqauth/react over @synqauth/nextjs’s route mount, so it needs a server of yours. In a single-page app, createAccountClient from @synqauth/js makes and revokes them (apiKeys). @synqauth/js in the docs

Call the demo API with a key

src/examples/api-keys/WithUi.tsx
'use client'

import { AccountManager } from '@synqauth/react'

// API keys with Synq's UI: AccountManager's API keys section, which shows
// wherever one of the brand's APIs lets people make keys. The person picks
// the API and what the key may do; the key shows once, with a copy button,
// and a revoked key stops working at its API's next check. Making one asks
// for a recent sign-in, since a key outlives every session.
export function ApiKeysWithUi() {
  return <AccountManager sections={['apiKeys']} />
}