Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add realtime / react hooks examples snippet #1770

Merged
merged 2 commits into from
Mar 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/frontend/react-hooks/overview.mdx
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ sidebarTitle: Overview
description: Using the Trigger.dev v3 API from your React application.
---

import RealtimeExamplesCards from "/snippets/realtime-examples-cards.mdx";

Our react hooks package provides a set of hooks that make it easy to interact with the Trigger.dev API from your React application, using our [frontend API](/frontend/overview). You can use these hooks to fetch runs, and subscribe to real-time updates, and trigger tasks from your frontend application.

## Installation
@@ -331,3 +333,5 @@ See our [Realtime hooks documentation](/frontend/react-hooks/realtime) for more
## Trigger Hooks

See our [Trigger hooks documentation](/frontend/react-hooks/triggering) for more information.

<RealtimeExamplesCards />
4 changes: 4 additions & 0 deletions docs/frontend/react-hooks/realtime.mdx
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ sidebarTitle: Realtime
description: Get live updates from the Trigger.dev API in your frontend application.
---

import RealtimeExamplesCards from "/snippets/realtime-examples-cards.mdx";

These hooks allow you to subscribe to runs, batches, and streams using [Trigger.dev realtime](/realtime). Before reading this guide:

- Read our [Realtime documentation](/realtime) to understand how the Trigger.dev realtime API works.
@@ -414,3 +416,5 @@ export function MyComponent({
);
}
```

<RealtimeExamplesCards />
4 changes: 4 additions & 0 deletions docs/frontend/react-hooks/triggering.mdx
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ sidebarTitle: Triggering
description: Triggering tasks from your frontend application.
---

import RealtimeExamplesCards from "/snippets/realtime-examples-cards.mdx";

We provide a set of hooks that can be used to trigger tasks from your frontend application.

## Demo
@@ -248,3 +250,5 @@ export function MyComponent({ publicAccessToken }: { publicAccessToken: string }
);
}
```

<RealtimeExamplesCards />
10 changes: 7 additions & 3 deletions docs/realtime/overview.mdx
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ sidebarTitle: Overview
description: Using the Trigger.dev v3 realtime API
---

import RealtimeExamplesCards from "/snippets/realtime-examples-cards.mdx";

Trigger.dev Realtime is a set of APIs that allow you to subscribe to runs and get real-time updates on the run status. This is useful for monitoring runs, updating UIs, and building realtime dashboards.

## How it works
@@ -17,9 +19,9 @@ The Realtime API is built on top of [Electric SQL](https://electric-sql.com/), a
height="315"
src="https://www.youtube.com/embed/RhJAbSGkS88?si=4Z72SfygeklNI3As"
title="YouTube video player"
allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerPolicy="strict-origin-when-cross-origin"
allowFullScreen
allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerPolicy="strict-origin-when-cross-origin"
allowFullScreen
/>

## Usage
@@ -266,3 +268,5 @@ The Realtime API in the Trigger.dev Cloud limits the number of concurrent subscr
## Known issues

There is currently a known issue where the realtime API does not work if subscribing to a run that has a large payload or large output and are stored in object store instead of the database. We are working on a fix for this issue: https://github.com/triggerdotdev/trigger.dev/issues/1451. As a workaround you'll need to keep payloads and outputs below 128KB when using the realtime API.

<RealtimeExamplesCards />
4 changes: 4 additions & 0 deletions docs/realtime/streams.mdx
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ sidebarTitle: Streams
description: Stream data in realtime from inside your tasks
---

import RealtimeExamplesCards from "/snippets/realtime-examples-cards.mdx";

The world is going realtime, and so should your tasks. With the Streams API, you can stream data from your tasks to the outside world in realtime. This is useful for a variety of use cases, including AI.

## How it works
@@ -449,3 +451,5 @@ export const aiStreamingWithTools = schemaTask({
},
});
```

<RealtimeExamplesCards />
54 changes: 54 additions & 0 deletions docs/snippets/realtime-examples-cards.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## Examples

<CardGroup cols={2}>
<Card
title="Image Generation with fal.ai"
icon="image"
href="/guides/example-projects/realtime-fal-ai"
>
A Next.js app that uses the Realtime API and react hooks to create on-demand image generation
through fal.ai's services.
</Card>
<Card
title="Realtime CSV Importer"
icon="file-csv"
href="/guides/example-projects/realtime-csv-importer"
>
Upload CSV files and view the progress of the task being processed on the frontend live using
the Realtime API.
</Card>
<Card
title="Batch LLM Evaluator"
icon="sparkles"
href="/guides/example-projects/batch-llm-evaluator"
>
A Next.js app that uses the Realtime API and react hooks to evaluate language model responses on
the frontend in real-time.
</Card>
<Card
title="Claude Thinking Chatbot"
icon="messages"
href="/guides/example-projects/claude-thinking-chatbot"
>
A chatbot that demonstrates Claude 3.7's thinking capabilities through the Realtime API and
react hooks.
</Card>

</CardGroup>

### Learn more

<CardGroup cols={2}>
<Card title="View all our guides & examples" icon="books" href="/guides">
Guides, example projects and example tasks. Copy any of the code and use it in your own
projects.
</Card>
<Card
title="Example projects repo"
icon="github"
href="https://github.com/triggerdotdev/examples"
>
Star/Fork our examples repo to learn more about how to use Trigger.dev in full stack
applications.
</Card>
</CardGroup>