---
title: 'Router from Client'
description: 'Turn an oRPC client into a router with createRouterFromClient.'
sidebar:
  label: 'Router from Client'
---

## Overview

`createRouterFromClient` turns a [client](/docs/client/client-side) into a [router](/docs/router) that forwards every call to it. Use the router anywhere a router is accepted, such as a [handler](/docs/rpc/handler):

```ts
import { createRouterFromClient } from '@orpc/server'

const router = createRouterFromClient(contract, client)
```

`contract` can be a [contract](/docs/contract-first) or a [router without lazy children](/docs/contract/router#router-to-contract). A router's handlers and middlewares are ignored.

## Context

The router context is passed to the client as its [client context](/docs/client/client-side#client-context):

```ts
const client: RouterContractClient<typeof contract, { token: string }> = createORPCClient(link)

const router = createRouterFromClient(contract, client)

const handler = new RPCHandler(router)

await handler.handle(request, {
  context: { token: 'token' }, // <- the client context
})
```

## Validation

The router does not validate input, output or errors, it just forwards calls to the client. For validation, consider the [Request Validation](/docs/plugins/request-validation) and [Response Validation](/docs/plugins/response-validation) plugins on the client's link.
