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:
| Config | Where connectUrl points | What you build |
|---|---|---|
hub: { ... } | Corsair Hub hosted UI | Delivery endpoint only |
manual: { baseUrl, redirectUri } | Your app’s connect page | Connect page + OAuth callback |
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
app/api/corsair/route.ts
app/api/corsair/[...path]/route.ts
backend.ts
| Field | Purpose |
|---|---|
plugin | Optional — omit to show all configured plugins |
oauthMode | "byo" (your OAuth app) or "managed" (Corsair’s) |
source | "client" or "server" — inferred from deliveryUrl when omitted |
deliveryUrl. 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
| Status | error | When |
|---|---|---|
| 500 | connect_not_configured | Neither hub nor manual config was passed |
| 500 | connect_misconfigured | Invalid manual.baseUrl, or missing connect URLs for manual connect |
| 500 | database_not_configured | database and kek required to issue connect links |
| 400 | missing_credentials | Plugin OAuth client id / secret not configured (manual mode BYO) |
| 400 | hub_mode | resolve or oauthCallback called when only hub is configured |
| 500 | resolve_failed | State invalid or expired (manual mode) |
| 502 | oauth_callback_failed | Provider rejected the code (manual mode) |
CorsairClientError with these code values.