You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/realtime/backend/input-streams.mdx
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,15 +7,15 @@ description: Send data into running tasks from your backend code
7
7
The Input Streams API allows you to send data into running Trigger.dev tasks from your backend code. This enables bidirectional communication — while [output streams](/realtime/backend/streams) let you read data from tasks, input streams let you push data into them.
8
8
9
9
<Note>
10
-
To learn how to receive input stream data inside your tasks, see our [Input
11
-
Streams](/tasks/input-streams)documentation.
10
+
To learn how to receive input stream data inside your tasks, see [Input
11
+
Streams](/tasks/streams#input-streams)in the Streams doc.
12
12
</Note>
13
13
14
14
## Sending data to a running task
15
15
16
16
### Using defined input streams (Recommended)
17
17
18
-
The recommended approach is to use [defined input streams](/tasks/input-streams#defining-input-streams) for full type safety:
18
+
The recommended approach is to use [defined input streams](/tasks/streams#defining-input-streams) for full type safety:
For more information on defining and using streams, see the [Realtime Streams v2](/tasks/streams) documentation.
154
+
For more information on defining and using streams, see the [Realtime Streams](/tasks/streams) documentation.
155
+
156
+
## useInputStreamSend
157
+
158
+
The `useInputStreamSend` hook lets you send data from your frontend into a running task's [input stream](/tasks/streams#input-streams). Use it for cancel buttons, approval forms, or any UI that needs to push typed data into a running task.
159
+
160
+
### Basic usage
161
+
162
+
Pass the input stream's `id` (string), the run ID, and options such as `accessToken`. You typically get `runId` and `accessToken` from the object returned when you trigger the task (e.g. `handle.id`, `handle.publicAccessToken`). The hook returns `send`, `isLoading`, `error`, and `isReady`:
-**`streamId`**: The input stream identifier (string). Use the `id` from your defined stream (e.g. `approval.id`) or the same string you used in `streams.input<T>({ id: "approval" })`.
207
+
-**`runId`**: The run to send input to. When `runId` is undefined, `isReady` is false and `send` will not trigger.
208
+
-**`options`**: `accessToken` (required for client usage), `baseURL` (optional). See [Realtime auth](/realtime/auth) for generating a public access token with the right scopes (e.g. input streams write for that run).
209
+
210
+
Return value:
211
+
212
+
-**`send(data)`**: Sends typed data to the input stream. Uses SWR mutation under the hood.
213
+
-**`isLoading`**: True while a send is in progress.
214
+
-**`error`**: Set if the last send failed.
215
+
-**`isReady`**: True when both `runId` and access token are available.
216
+
217
+
For receiving input stream data inside a task (`.wait()`, `.once()`, `.on()`), see [Input Streams](/tasks/streams#input-streams) in the Streams doc.
0 commit comments