> ## 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.

# Next.js

> Mount the Corsair /api/corsair route in a Next.js App Router app.

Corsair mounts one route that serves Hub delivery and the management API. In the App Router, use `toNextJsHandler`.

## Configure Corsair

```ts corsair.ts theme={null}
import { createCorsair } from 'corsair';
import { github } from '@corsair-dev/github';

export const corsair = createCorsair({
    plugins: [github({ authType: 'managed' })],
    database: db,
    kek: process.env.CORSAIR_KEK!,
    hub: {
        projectApiKey: process.env.CORSAIR_DEV_API_KEY!,
        signingSecret: process.env.CORSAIR_DEV_SIGNING_SECRET!,
    },
});
```

## Mount the route

```ts app/api/corsair/[[...path]]/route.ts theme={null}
import { toNextJsHandler } from 'corsair';
import { corsair } from '@/server/corsair';

export const { GET, POST, OPTIONS } = toNextJsHandler(corsair, {
    basePath: '/api/corsair',
});
```

<Note>Pages Router? Export a catch-all API route at `pages/api/corsair/[...path].ts` and forward `req`/`res` through the same `toNextJsHandler`. The App Router is the supported default.</Note>

## Run and go green

Start the dev server. On the first request to `/api/corsair`, your app self-registers its delivery URL and the Hub dashboard header dot turns green. See [Delivery URLs](/hub/delivery-urls).

<CardGroup cols={2}>
  <Card title="Hub setup" href="/hub/setup">Create a project, copy keys, reach the green check.</Card>
  <Card title="Add a plugin" href="/guides/plugins">GitHub, Slack, Linear, and more.</Card>
</CardGroup>
