LiveKit docs › Hooks › useRpc

---

# useRpc

> ℹ️ **Note**
> 
> This feature is under active development and may change based on developer feedback and real-world usage.

Hook for declarative RPC method registration and outbound RPC calls.

Registers a handler for an incoming RPC method and returns a `performRpc` function for outbound calls. The handler is registered on mount and unregistered on unmount. Handler identity does not matter (captured by ref), so inline functions work without `useCallback`.

## Import

```typescript
import { useRpc } from "@livekit/components-react";

```

## Usage

```tsx
const { performRpc } = useRpc(
  session,
  "getUserLocation",
  async (payload: { highAccuracy: boolean }) => {
    const pos = await getPosition(payload.highAccuracy);
    return { lat: pos.coords.latitude, lng: pos.coords.longitude };
  }
);

```

## Properties

- **`handler`** _(RpcHandler<SerializerInput<S>, SerializerOutput<S>>)_: 

- **`methodName`** _(string)_: 

- **`session`** _(UseSessionReturn)_: 

## Returns

```typescript
UseRpcReturn;

```

---

This document was rendered at 2026-06-07T11:32:02.532Z.
For the latest version of this document, see [https://docs.livekit.io/reference/components/react/hook/userpc.md](https://docs.livekit.io/reference/components/react/hook/userpc.md).

To explore all LiveKit documentation, see [llms.txt](https://docs.livekit.io/llms.txt).