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

# Referencia

> Helpers exported by @markpdf/nextjs.

# Referencia

## `createConvertRouteHandler(config)`

```ts theme={null}
import { createConvertRouteHandler } from "@markpdf/nextjs";

export const { POST } = createConvertRouteHandler({
  apiKey: string,
  baseUrl?: string,
  defaultOptions?: ConvertOptions,
  maxUploadBytes?: number,
  allowQueryOverrides?: boolean, // default true — perlimit ?mode=quality en la URL del handler
});
```

Returns `{ POST }`, ready to re-export from `route.ts`. The handler accepts `multipart/form-data` with a `file` field (configurable, see `fileField` below) and returns the API response as is.

## `convertFormData(formData, options)`

```ts theme={null}
import { convertFormData } from "@markpdf/nextjs";

const markdown = await convertFormData(formData, {
  apiKey: string,
  fileField?: string,       // default "file"
});
```

Extracts the file from a `FormData` (typically received as an argument to a Server Action) and calls `convertFile` of the underlying SDK. Intended to be used within a `"use server"` function.

## `convertUrlAction(url, options)`

```ts theme={null}
import { convertUrlAction } from "@markpdf/nextjs";

const markdown = await convertUrlAction(url, {
  apiKey: string,
  ...ConvertOptions,
});
```

Direct wrapper for `convertFromUrl` of SDK, intended for Server Actions that receive a pre-signed URL instead of a file.

## `getServerClient(config)`

```ts theme={null}
import { getServerClient } from "@markpdf/nextjs";

const client = getServerClient({ apiKey: process.env.MARKPDF_API_KEY! });
```

Returns a cached instance of `MarkpdfClient` (memoized by `apiKey` + `baseUrl` within the same process) for when you need direct access to the entire client — for example, to use `pdfIndex`, `convertStream`, or `getJob` within a custom Route Handler or Server Action.

```ts app/api/index/route.ts theme={null}
import { getServerClient } from "@markpdf/nextjs";
import { NextResponse } from "next/server";

export async function POST(req: Request) {
  const { url } = await req.json();
  const client = getServerClient({ apiKey: process.env.MARKPDF_API_KEY! });
  const spine = await client.pdfIndex(url);
  return NextResponse.json(spine);
}
```

## Tipos re-exportados

`@markpdf/nextjs` re-exports the `@markpdf/sdk` types so you don't need to install it separately if you only use the high-level helpers:

```ts theme={null}
import type {
  ConvertOptions,
  ConversionResult,
  PdfSpine,
  JobStatus,
  MarkpdfError,
} from "@markpdf/nextjs";
```

See [Node.js SDK Reference](/docs/sdks/nodejs/reference) for field-by-field details of each type.
