# Next.js (/docs/reference/next)

```ts
import { … } from "@monarcode/session-kit/next";
```

Guide: [Next.js](/docs/setups/next).

## Functions [#functions]

### nextJar [#nextjar]

The `CookieJar` for `cookies()` from `next/headers`, to pass to `serverAuth` from `@monarcode/session-kit/server`.

### proxyJar [#proxyjar]

The `CookieJar` for a request in Next's Proxy (`proxy.ts`). It reads `request`'s cookies and sets new ones on `response`. Use it with `serverAuth.refreshIfDue`, so the pages that render the request see a fresh token through [`nextJar`](#nextjar).

## Types [#types]

### NextCookies [#nextcookies]

A request's cookie store, as `cookies()` from `next/headers` resolves it. [`nextJar`](#nextjar) reads and writes it, and Next's own store fits.

### NextJarOptions [#nextjaroptions]

Options for [`nextJar`](#nextjar).

### NextJarOptions

Options for nextJar.

| Prop        | Type    | Description                                                                                                                                                                                                |
| ----------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `writable?` | `union` | Whether the jar can set cookies. Pass `true` in a Server Function (an action) or a Route Handler. Server Components can't set cookies, so there the jar is read-only and never refreshes. Default: `false` |

### ProxyRequest [#proxyrequest]

The request [`proxyJar`](#proxyjar) reads cookies from. A `NextRequest` fits.

### ProxyResponse [#proxyresponse]

The response [`proxyJar`](#proxyjar) sets cookies on. A `NextResponse` fits.