---
title: "RPC"
description: "This page lists the TypeScript SDK names for RPCs."
canonical_url: "https://docs.superdurable.io/zh-Hans/reference/typescript/rpc/"
source: "docs/reference/typescript/rpc.mdx"
locale: "zh-Hans"
---

# RPC

This page lists the TypeScript SDK names for [RPCs](https://docs.superdurable.io/zh-Hans/concepts/primitives/rpc.md).
The doc comment of each API gives its parameters, defaults, and errors. Read
them in the [TypeScript SDK API reference](https://docs.superdurable.io/zh-Hans/reference/typescript.md#api-reference).

<a id="api-names"></a>

## API names

| Task                                                 | TypeScript API                                                                                                                                 | Dex behavior                                                                                                                           |
| ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| Define an RPC handler                                | **@rpc** on a Flow method, or **declareRPCMethod**                                                                                             | [Flow definition](https://docs.superdurable.io/zh-Hans/reference/typescript/flow.md#flow-definition)                                   |
| Set the durable RPC name                             | **name** of **RPCOptions**. It defaults to the method name.                                                                                    | [Flow definition](https://docs.superdurable.io/zh-Hans/reference/typescript/flow.md#flow-definition)                                   |
| Set the RPC timeout                                  | **timeoutMs** of **RPCOptions**                                                                                                                | [RPC timeout](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#rpc-timeout)                                       |
| Lock Attributes for the whole call                   | **lockAttributes** of **RPCOptions**                                                                                                           | [Locks](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#attribute-locks)                                         |
| Request transactional reads and writes without locks | **isTransactional** of **RPCOptions**                                                                                                          | [Transactional RPCs](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#transactional-reads-and-writes)             |
| Load AttributeMap values and Channel messages        | **loadAttributeMaps**, **loadAttributeMapInstances**, **loadChannels**, **loadChannelMaps**, and **loadChannelMapInstances** of **RPCOptions** | [Selective state loading](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#load-collection-state)                 |
| Return the output and start next Steps               | **RPCResult**, with **output** and **nextSteps**                                                                                               | [RPCs](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#rpcs)                                                     |
| Cancel running Steps                                 | **cancelingSteps** of **RPCResult**                                                                                                            | [Cancel running Steps](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#cancel-running-steps)                     |
| Let a person invoke the RPC from Dex Web             | **action** of **RPCOptions**, with **Action**                                                                                                  | [Actions](https://docs.superdurable.io/zh-Hans/reference/web/dex-web.md#actions)                                                       |
| Invoke the RPC from a Client                         | **Client.invokeRPC**                                                                                                                           | [Invoke an RPC](https://docs.superdurable.io/zh-Hans/reference/server/runtime-client.md#invoke-an-rpc)                                 |
| Lock or load map instances chosen at call time       | **RPCInvokeOptions**, with **Client.invokeRPCWithOptions**                                                                                     | [Runtime-selected map instances](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#runtime-selected-map-instances) |

**@rpc** and **declareRPCMethod** take the same **RPCOptions**.

<a id="rpc-codecs"></a>

## RPC codecs

TypeScript uses JSON when **inputCodec** or **outputCodec** is omitted. Provide
a codec when the input or output is not JSON, including scalar values such as
strings, numbers, booleans, and bigints.

<a id="example"></a>

## Example

Example: [examples/typescript/src/primitives/rpc/rpc-flow.ts](https://github.com/superdurable/dex/tree/main/examples/typescript/src/primitives/rpc/rpc-flow.ts)
