# Overview

> 

tRPC is not a server on its own, and must therefore be served using other hosts, such as a simple [Node.js HTTP Server](https://trpc.io/docs/server/adapters/standalone.md), [Express](https://trpc.io/docs/server/adapters/express.md), or even [Next.js](https://trpc.io/docs/server/adapters/nextjs.md). Most tRPC features are the same no matter which backend you choose. **Adapters** act as the glue between the host system and your tRPC API.

Adapters typically follow some common conventions, allowing you to set up context creation via `createContext`, and globally handle errors via `onError`, but importantly allow you to choose an appropriate host for your application.

We support many modes of hosting an API, which you will find documented here.

- For serverful APIs, you might want our [Standalone](https://trpc.io/docs/server/adapters/standalone.md) adapter, or use the [Express](https://trpc.io/docs/server/adapters/express.md) or [Fastify](https://trpc.io/docs/server/adapters/fastify.md) adapters to hook into your existing APIs
- You might want a serverless solution and choose [AWS Lambda](https://trpc.io/docs/server/adapters/aws-lambda.md), or [Fetch](https://trpc.io/docs/server/adapters/fetch.md) for edge runtimes
- You might have a full-stack framework and want a full integration like [Next.js](https://trpc.io/docs/server/adapters/nextjs.md), or you could use the [Fetch](https://trpc.io/docs/server/adapters/fetch.md) adapter with Next.js, Astro, Remix, or SolidStart

> [!TIP]
> For local development or serverful infrastructure, the simplest Adapter to use is the [Standalone Adapter](https://trpc.io/docs/server/adapters/standalone.md), which can be used to run a standard Node.js HTTP Server. We recommend this when you need to get started quickly and have no existing HTTP Server to integrate with. Swapping out later is trivial if your needs change.


## Common options

Every HTTP adapter accepts these options, next to its own (like `endpoint` for Fetch, or `basePath` for Standalone):

| Option                | Description                                                                                                                                         |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `router`              | Your app router. Required.                                                                                                                          |
| `createContext`       | Creates the [context](https://trpc.io/docs/server/context.md) for each request. It receives the adapter's own objects (e.g. `req` and `res`) plus `info`.                     |
| `onError`             | Called with `{ error, type, path, input, ctx, req }` for every error, e.g. to report it. See [Error handling](https://trpc.io/docs/server/error-handling.md#handling-errors). |
| `responseMeta`        | Returns `{ status, headers }` for the response, e.g. for [caching](https://trpc.io/docs/server/caching.md).                                                                   |
| `allowBatching`       | Set to `false` to reject batch requests. Defaults to `true`.                                                                                        |
| `maxBatchSize`        | Rejects batch requests with more calls than this with a `400 Bad Request`. Set `maxItems` on your batch link to the same or a lower value.          |
| `allowMethodOverride` | Accepts queries sent as `POST`, for clients that set `methodOverride: 'POST'` on their link. Defaults to `false`.                                   |

The Node.js adapters (Standalone, Express and Next.js) also accept:

- `maxBodySize`: the largest request body in bytes; larger ones are rejected with `413 PAYLOAD_TOO_LARGE`.
- `middleware`: a connect-style `(req, res, next)` function that runs before tRPC, e.g. [`cors()`](https://trpc.io/docs/server/adapters/standalone.md#handling-cors--options).

```ts title="server.ts"
import { createHTTPServer } from '@trpc/server/adapters/standalone';
import { appRouter } from './router';

createHTTPServer({
  router: appRouter,
  createContext: () => ({}),
  onError({ error, path }) {
    console.error(`tRPC error on '${path}':`, error);
  },
  maxBatchSize: 10,
  maxBodySize: 1_000_000, // 1 MB
}).listen(3000);
```
