LiveKit docs › Hooks › useLiveKitRoom

---

# useLiveKitRoom

The `useLiveKitRoom` hook is used to implement the `LiveKitRoom` or your custom implementation of it. It returns a `Room` instance and HTML props that should be applied to the root element of the component.

## Import

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

```

## Usage

```tsx
const { room, htmlProps } = useLiveKitRoom();
return <div {...htmlProps}>...</div>;

```

## Properties

- **`props.serverUrl`** _(string | undefined)_: URL to the LiveKit server. For example: `wss://<domain>.livekit.cloud` To simplify the implementation, `undefined` is also accepted as an intermediate value, but only with a valid string url can the connection be established.

- **`props.token`** _(string | undefined)_: A user specific access token for a client to authenticate to the room. This token is necessary to establish a connection to the room. To simplify the implementation, `undefined` is also accepted as an intermediate value, but only with a valid string token can the connection be established.

- **`props.audio`** _(AudioCaptureOptions | boolean)_ (optional): Publish audio immediately after connecting to your LiveKit room.

- **`props.connect`** _(boolean)_ (optional): If set to true a connection to LiveKit room is initiated.

- **`props.connectOptions`** _(RoomConnectOptions)_ (optional): Define options how to connect to the LiveKit server.

- **`props.onConnected`** _(() => void)_ (optional): 

- **`props.onDisconnected`** _((reason?: DisconnectReason) => void)_ (optional): 

- **`props.onEncryptionError`** _((error: Error) => void)_ (optional): 

- **`props.onError`** _((error: Error) => void)_ (optional): 

- **`props.onMediaDeviceFailure`** _((failure?: MediaDeviceFailure, kind?: MediaDeviceKind) => void)_ (optional): 

- **`props.options`** _(RoomOptions)_ (optional): Options for when creating a new room. When you pass your own room instance to this component, these options have no effect. Instead, set the options directly in the room instance.

- **`props.room`** _(Room)_ (optional): Optional room instance. By passing your own room instance you overwrite the `options` parameter, make sure to set the options directly on the room instance itself.

- **`props.screen`** _(ScreenShareCaptureOptions | boolean)_ (optional): Publish screen share immediately after connecting to your LiveKit room.

- **`props.simulateParticipants`** _(number | undefined)_ (optional): 

- **`props.video`** _(VideoCaptureOptions | boolean)_ (optional): Publish video immediately after connecting to your LiveKit room.

## Returns

```typescript
{
  room: Room | undefined;
  htmlProps: HTMLAttributes<T>;
}

```

---

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

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