client.connect.createLink(), redirects them to the returned connectUrl, and Corsair handles the rest.
The same API works in both modes — hub or manual config on createCorsair picks the backend:
New to the difference? Hub overview explains the relay model and Manual or Hub compares the two side by side. This page is the API reference for both.
Response shape
EverycreateLink call returns:
connectUrl. That is the entire client-side contract.
Hub mode (hosted connect UI)
Use this when you want Corsair Hub to handle the connect pages, OAuth redirects, and token delivery.server.ts
ck_dev_…) locally and a production key (ck_prod_…) when deployed. See Environments.
Mount one route (optional catch-all so bare /api/corsair hits hub delivery too):
app/api/corsair/[[...path]]/route.ts
toNextJsHandler serves hub delivery at the base path (GET ?d=…, signed POST, OPTIONS CORS) and the management API on subpaths (/ok, /connect/links, etc.).
Create a connect link and redirect:
backend.ts
Hub delivers results to your handler. In development the SDK auto-detects the delivery URL; in production it uses the URL registered in the Hub dashboard. You do not call
resolve or oauthCallback.
Manual mode (self-hosted)
Use this when you want full control over connect pages and OAuth callbacks.server.ts
- Connect page at
manual.baseUrl— receives?state=…, resolves to the provider OAuth URL - OAuth callback at
manual.redirectUri— receives?code=…&state=…, exchanges for tokens
Step 1 — Create the connect link
backend.ts
connect-button.tsx
state is embedded in connectUrl as a query parameter — you do not need to handle it separately.
Step 2 — Resolve
The browser hits your connect page with?state=…. Call resolve to get the provider OAuth URL:
corsair.manage.connect.resolve(state) in-process.
Step 3 — OAuth callback
The provider redirects back with?code=…&state=…:
app/api/oauth/callback/route.ts
Checking connection status
After a successful connect,useConnectionStatus({ tenantId }) reflects the new state:
status.tsx
refetch() after connect completes to update the dashboard.
Errors
All client errors surface as
CorsairClientError with these code values.