LiveKit docs › Hooks › useEnsureTrackRef

---

# useEnsureTrackRef

Ensures that a track reference is provided, either via context or explicitly as a parameter. If not inside a `TrackRefContext` and no track reference is provided, an error is thrown.

## Import

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

```

## Properties

- **`trackRef`** _(TrackReferenceOrPlaceholder)_ (optional): 

## Returns

```typescript
TrackReferenceOrPlaceholder;

```

---

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

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