Skip to content

Commit 70325e4

Browse files
committed
WIP realtime/frontend docs
1 parent 3d7a6d8 commit 70325e4

File tree

7 files changed

+701
-23
lines changed

7 files changed

+701
-23
lines changed

docs/frontend/overview.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: Overview & Authentication
3+
sidebarTitle: Overview & Auth
4+
description: Using the Trigger.dev v3 API from your frontend application.
5+
---
6+
7+
Install the preview package: `0.0.0-realtime-20241021152316`.

docs/frontend/react-hooks.mdx

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
title: React hooks
3+
sidebarTitle: React hooks
4+
description: Using the Trigger.dev v3 API from your React application.
5+
---
6+
7+
## Installation
8+
9+
Install the preview package: `0.0.0-realtime-20241021152316`.
10+
11+
```bash
12+
npm install @trigger.dev/[email protected]
13+
```
14+
15+
## Authentication
16+
17+
You need to use the `TriggerAuthContext` provider to authenticate your requests.
18+
19+
```tsx
20+
import { TriggerAuthContext } from "@trigger.dev/react-hooks";
21+
22+
const App = () => {
23+
return (
24+
<TriggerAuthContext.Provider value={{ accessToken: "your-access-token" }}>
25+
<MyComponent />
26+
</TriggerAuthContext.Provider>
27+
);
28+
};
29+
```
30+
31+
## Usage
32+
33+
### useRun
34+
35+
The `useRun` hook allows you to fetch a run by its ID.
36+
37+
```tsx
38+
import { useRun } from "@trigger.dev/react-hooks";
39+
40+
const MyComponent = ({ runId }) => {
41+
const { data, error, isLoading } = useRun(runId);
42+
43+
if (isLoading) return <div>Loading...</div>;
44+
if (error) return <div>Error: {error.message}</div>;
45+
46+
return <div>Run: {data.id}</div>;
47+
};
48+
```
49+
50+
### useRealtimeRun
51+
52+
The `useRealtimeRun` hook allows you to subscribe to a run by its ID.
53+
54+
```tsx
55+
import { useRealtimeRun } from "@trigger.dev/react-hooks";
56+
57+
const MyComponent = ({ runId }) => {
58+
const { data, error, isLoading } = useRealtimeRun(runId);
59+
60+
if (isLoading) return <div>Loading...</div>;
61+
if (error) return <div>Error: {error.message}</div>;
62+
63+
return <div>Run: {data.id}</div>;
64+
};
65+
```
66+
67+
### useRealtimeRunsWithTag
68+
69+
The `useRealtimeRunsWithTag` hook allows you to subscribe to runs with a specific tag.
70+
71+
```tsx
72+
import { useRealtimeRunsWithTag } from "@trigger.dev/react-hooks";
73+
74+
const MyComponent = ({ tag }) => {
75+
const { data, error, isLoading } = useRealtimeRunsWithTag(tag);
76+
77+
if (isLoading) return <div>Loading...</div>;
78+
if (error) return <div>Error: {error.message}</div>;
79+
80+
return <div>Runs: {data.map((run) => run.id).join(", ")}</div>;
81+
};
82+
```
83+
84+
### useRealtimeBatch
85+
86+
The `useRealtimeBatch` hook allows you to subscribe to a batch by its ID.
87+
88+
```tsx
89+
import { useRealtimeBatch } from "@trigger.dev/react-hooks";
90+
91+
const MyComponent = ({ batchId }) => {
92+
const { data, error, isLoading } = useRealtimeBatch(batchId);
93+
94+
if (isLoading) return <div>Loading...</div>;
95+
if (error) return <div>Error: {error.message}</div>;
96+
97+
return <div>Batch: {data.id}</div>;
98+
};
99+
```

docs/mint.json

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"$schema": "https://mintlify.com/schema.json",
33
"name": "Trigger.dev",
4-
"openapi": ["/openapi.yml", "/v3-openapi.yaml"],
4+
"openapi": [
5+
"/openapi.yml",
6+
"/v3-openapi.yaml"
7+
],
58
"api": {
69
"playground": {
710
"mode": "simple"
@@ -111,27 +114,43 @@
111114
"navigation": [
112115
{
113116
"group": "Getting Started",
114-
"pages": ["introduction", "quick-start", "how-it-works", "upgrading-beta", "limits"]
117+
"pages": [
118+
"introduction",
119+
"quick-start",
120+
"how-it-works",
121+
"upgrading-beta",
122+
"limits"
123+
]
115124
},
116125
{
117126
"group": "Fundamentals",
118127
"pages": [
119128
{
120129
"group": "Tasks",
121-
"pages": ["tasks/overview", "tasks/scheduled"]
130+
"pages": [
131+
"tasks/overview",
132+
"tasks/schemaTask",
133+
"tasks/scheduled"
134+
]
122135
},
123136
"triggering",
124137
"runs-and-attempts",
125138
"apikeys",
126139
{
127140
"group": "Configuration",
128-
"pages": ["config/config-file", "config/extensions/overview"]
141+
"pages": [
142+
"config/config-file",
143+
"config/extensions/overview"
144+
]
129145
}
130146
]
131147
},
132148
{
133149
"group": "Development",
134-
"pages": ["cli-dev", "run-tests"]
150+
"pages": [
151+
"cli-dev",
152+
"run-tests"
153+
]
135154
},
136155
{
137156
"group": "Deployment",
@@ -141,7 +160,9 @@
141160
"github-actions",
142161
{
143162
"group": "Deployment integrations",
144-
"pages": ["vercel-integration"]
163+
"pages": [
164+
"vercel-integration"
165+
]
145166
}
146167
]
147168
},
@@ -153,7 +174,13 @@
153174
"errors-retrying",
154175
{
155176
"group": "Wait",
156-
"pages": ["wait", "wait-for", "wait-until", "wait-for-event", "wait-for-request"]
177+
"pages": [
178+
"wait",
179+
"wait-for",
180+
"wait-until",
181+
"wait-for-event",
182+
"wait-for-request"
183+
]
157184
},
158185
"queue-concurrency",
159186
"versioning",
@@ -167,13 +194,23 @@
167194
"context"
168195
]
169196
},
197+
{
198+
"group": "Frontend usage",
199+
"pages": [
200+
"frontend/overview",
201+
"frontend/react-hooks"
202+
]
203+
},
170204
{
171205
"group": "API reference",
172206
"pages": [
173207
"management/overview",
174208
{
175209
"group": "Tasks API",
176-
"pages": ["management/tasks/trigger", "management/tasks/batch-trigger"]
210+
"pages": [
211+
"management/tasks/trigger",
212+
"management/tasks/batch-trigger"
213+
]
177214
},
178215
{
179216
"group": "Runs API",
@@ -212,7 +249,9 @@
212249
},
213250
{
214251
"group": "Projects API",
215-
"pages": ["management/projects/runs"]
252+
"pages": [
253+
"management/projects/runs"
254+
]
216255
}
217256
]
218257
},
@@ -258,11 +297,17 @@
258297
},
259298
{
260299
"group": "Help",
261-
"pages": ["community", "help-slack", "help-email"]
300+
"pages": [
301+
"community",
302+
"help-slack",
303+
"help-email"
304+
]
262305
},
263306
{
264307
"group": "",
265-
"pages": ["guides/introduction"]
308+
"pages": [
309+
"guides/introduction"
310+
]
266311
},
267312
{
268313
"group": "Frameworks",
@@ -321,16 +366,20 @@
321366
},
322367
{
323368
"group": "Dashboard",
324-
"pages": ["guides/dashboard/creating-a-project"]
369+
"pages": [
370+
"guides/dashboard/creating-a-project"
371+
]
325372
},
326373
{
327374
"group": "Migrations",
328-
"pages": ["guides/use-cases/upgrading-from-v2"]
375+
"pages": [
376+
"guides/use-cases/upgrading-from-v2"
377+
]
329378
}
330379
],
331380
"footerSocials": {
332381
"twitter": "https://twitter.com/triggerdotdev",
333382
"github": "https://github.com/triggerdotdev",
334383
"linkedin": "https://www.linkedin.com/company/triggerdotdev"
335384
}
336-
}
385+
}

0 commit comments

Comments
 (0)