Skip to main content
When a user clicks “Connect GitHub” in your dashboard, your backend calls 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

Every createLink call returns:
Redirect to 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
Use a development key (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-specific optional overrides (ignored in manual mode): 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
Mount the management handler and build two pages:
  1. Connect page at manual.baseUrl — receives ?state=…, resolves to the provider OAuth URL
  2. OAuth callback at manual.redirectUri — receives ?code=…&state=…, exchanges for tokens
backend.ts
In React:
connect-button.tsx
The signed 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:
Or use corsair.manage.connect.resolve(state) in-process.

Step 3 — OAuth callback

The provider redirects back with ?code=…&state=…:
app/api/oauth/callback/route.ts
Corsair re-verifies the state, exchanges the code, encrypts tokens, and stores them.

Checking connection status

After a successful connect, useConnectionStatus({ tenantId }) reflects the new state:
status.tsx
Call refetch() after connect completes to update the dashboard.

Errors

All client errors surface as CorsairClientError with these code values.