39 lines
1.0 KiB
Plaintext
39 lines
1.0 KiB
Plaintext
---
|
|
title: useRealtimeRun
|
|
sidebarTitle: useRealtimeRun
|
|
description: Subscribes to all changes to a run in a React component.
|
|
---
|
|
|
|
import RunObject from "/snippets/realtime/run-object.mdx";
|
|
|
|
<RequestExample>
|
|
|
|
```ts Example
|
|
import { useRealtimeRun } from "@trigger.dev/react-hooks";
|
|
import type { myTask } from "./trigger/tasks";
|
|
|
|
export function MyComponent({ runId }: { runId: string }) {
|
|
const { run, error } = useRealtimeRun<typeof myTask>(runId);
|
|
|
|
if (error) return <div>Error: {error.message}</div>;
|
|
|
|
return <div>Run: {run.id}</div>;
|
|
}
|
|
```
|
|
|
|
</RequestExample>
|
|
|
|
This react hook subscribes to all changes to a run. See the [React hooks doc](/frontend/react-hooks) for more information on how to use this hook.
|
|
|
|
### Response
|
|
|
|
The react hook returns an object with the following properties:
|
|
|
|
<ParamField path="run" type="object" required>
|
|
The run object. See the [Run object doc](realtime/overview#run-object) for more information.
|
|
</ParamField>
|
|
|
|
<ParamField path="error" type="Error">
|
|
An error object if an error occurred while subscribing to a run.
|
|
</ParamField>
|