> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Nango plugin

> Manage Nango integrations, connections, Connect sessions, syncs and synced records, call tools, and proxy requests to your end users' APIs.

Use **Nango** through Corsair: one client, typed API calls.

The [Nango API](https://nango.dev/docs/reference/api) authenticates with an environment secret key (Environment settings > API keys). Use the key of the environment you want the agent to work in (dev or prod); a scoped key limits which operations succeed.

The plugin covers integrations, connections, Connect sessions, functions, syncs and records, tool calls, legacy actions, providers, environment variables and the proxy (GET, POST, PUT, PATCH, DELETE).

**Secrets.** `connections.get` drops the connection's third-party credentials unless you pass `include_credentials: true`, and `connections.import` never returns the credentials it sent. `integrations.get` with `include: ["credentials"]` and `environment.getVariables` return secrets in plain text. Errors never carry the request body or the environment key.

**Risk.** Proxy writes, tool calls and legacy actions act on your end customer's third-party account, so they are `destructive`, as are deletes, `connections.setMetadata` (replaces all metadata) and `connections.import` (can overwrite a connection's credentials).

Not included: environment and API-key administration, webhook signing-key rotation, function compile/deploy, sync variants, record pruning and inbound webhooks.

**What you get:**

* 35 typed API operations

## Setup

**1. Install**

```bash npm theme={null}
npm install corsair @corsair-dev/nango better-sqlite3
npm install --save-dev @types/better-sqlite3
```

```bash yarn theme={null}
yarn add corsair @corsair-dev/nango better-sqlite3
yarn add --dev @types/better-sqlite3
```

```bash pnpm theme={null}
pnpm install corsair @corsair-dev/nango better-sqlite3
pnpm install --save-dev @types/better-sqlite3
```

```bash bun theme={null}
bun add corsair @corsair-dev/nango better-sqlite3
bun add --dev @types/better-sqlite3
```

**2. Add the plugin**

```ts corsair.ts theme={null}
import Database from 'better-sqlite3';
import { createCorsair } from 'corsair';
import { nango } from '@corsair-dev/nango';

export const corsair = createCorsair({
	plugins: [
		nango(),
	],
	database: new Database('corsair.db'),
	kek: process.env.CORSAIR_KEK!,
	multiTenancy: true,
	hub: {
		projectApiKey: process.env.CORSAIR_API_KEY!,
		signingSecret: process.env.CORSAIR_SIGNING_SECRET!,
	},
});
```

With `multiTenancy: true`, scope calls with `corsair.withTenant(id)`. See [Quick start](https://docs.corsair.dev/quick-start.md) for KEK + Hub keys, and [Multi-tenancy](https://docs.corsair.dev/concepts/multi-tenancy.md) for account isolation.

**3. Choose authentication**

> [tab] API Key (Recommended)
>
> Store the Nango API key before the first call: `pnpm corsair setup --plugin=nango --tenant=acme api_key=<your-key>` (leave out `--tenant` without `multiTenancy`), or pass it as `key` in the plugin options. With Hub, each tenant enters their own key on the connect page. See [API key auth](https://docs.corsair.dev/concepts/api-key).
>
> ```ts theme={null}
> nango()
> ```
>
> More: [API Key](https://docs.corsair.dev/concepts/api-key)

**4. Connect a tenant**

Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see [Connect / OAuth](https://docs.corsair.dev/management/connect).

```ts theme={null}
const { connectUrl } = await corsair.manage.connect.createLink({
	plugin: 'nango',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**`connections.list`**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.nango.api.connections.list({
	tags: { end_user_id: 'user-123' },
	limit: 20,
});
```

**`sessions.create`**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.nango.api.sessions.create({
	tags: { end_user_id: 'user-123' },
	allowed_integrations: ['github'],
});
```

See the full list on the [API](https://docs.corsair.dev/plugins/nango/api.md) page.

## What's next

> [card] [API reference](https://docs.corsair.dev/plugins/nango/api.md)
>
> Every `nango.api.*` operation with input and output types.

> [card] [Connect / OAuth](https://docs.corsair.dev/management/connect)
>
> createLink, Hub delivery, and tenant connect flows.

> [card] [Use with agents](https://docs.corsair.dev/mcp-adapters/mcp-adapters)
>
> Expose this plugin's operations as MCP tools.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.