---
title: Local Calls
description: Run a route in the same process with call(), without HTTP.
---

`call()` runs one route without HTTP, such as in a test of a single route:

```ts twoslash
import { call, route } from "@rest-rpc/server";
import * as z from "zod";

const get = route
	.get("/posts/:id")
	.params(z.object({ id: z.coerce.number() }))
	.handler(({ params }) => ({
		id: params.id,
		title: "Hello",
		body: "First post",
	}));

const response = await call(get, { params: { id: 1 } });
```

- It takes the same request and returns the same result as a client call.
- The request and response are validated, and middleware runs, as over HTTP.
- Nothing is encoded or decoded, so the result is the handler's validated
  output, not what JSON would make of it.
- It rejects like a client call, so [`safe()`](/docs/errors#with-safe) works
  with it.

```ts
type CallOptions = {
	/** The initial context the route declares. Required when it declares any. */
	context?: object;
	/** Passed to the handler. Never aborts by default. */
	signal?: AbortSignal;
};
```

:::tip
To test the whole app, including encoding and interceptors, pass the app's
`fetch` to a [client](/docs/client/fetch-client#custom-fetch) instead.
:::
