createCorsairClient({ baseURL }) returns a typed client that mirrors every route on the handler. Use it from a Node script, a CLI, a worker, or a non-React frontend.
client.ts
createCorsairReactClient. It wraps this one and adds hooks.
Reading
reads.ts
client.tenants.list() in your editor shows Promise<Tenant[]>, and so on.
connectionStatus.get returns a Record<string, 'connected' | 'missing_credentials' | 'not_connected'> keyed by plugin id:
Writing
writes.ts
client.* is the HTTP mirror of corsair.manage.*; client.connect also carries .resolve and .oauthCallback. Connect/OAuth methods are documented on the Connect page.
Options
baseURL is the origin + base path the handler is mounted at, e.g. https://app.example.com/api/corsair. A trailing slash is tolerated.
fetch is optional. See Custom fetch below.
Need auth headers, custom retry, or interceptors? Pass a wrapped fetch:
Error handling
Failed requests throwCorsairClientError:
Error. CorsairClientError is only used when the server responded with a non-2xx body.
Custom fetch
When you callcreateCorsairClient, the client picks its fetch function once, either the one you pass in, or globalThis.fetch at that moment. Every later call (client.tenants.list(), etc.) uses that same function; it does not re-read globalThis.fetch on each request.
In a normal browser or Node 18+ app, this makes no practical difference. fetch is already available when you create the client, and it stays the same.
It only matters in two cases:
- Tests: your test runner or jsdom may install or replace
fetchafter your client module is imported. Pass an explicitfetchso the client uses the right one. - Custom behavior: auth headers, retries, or routing requests to an in-process handler instead of over HTTP.
globalThis.fetch, the client will not pick up the change. Create the client after your environment is ready, or pass fetch explicitly.