Skip to content

Commit 51a054f

Browse files
committed
Added Realtime CSV importer to the docs
1 parent efd61f1 commit 51a054f

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

docs/guides/example-projects/batch-llm-evaluator.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: "Batch LLM Evaluator"
2+
title: "Next.js Batch LLM Evaluator"
33
sidebarTitle: "Batch LLM Evaluator"
4-
description: "This example project evaluates multiple LLM models using the Vercel AI SDK and streams updates to the frontend using Trigger.dev Realtime."
4+
description: "This example Next.js project evaluates multiple LLM models using the Vercel AI SDK and streams updates to the frontend using Trigger.dev Realtime."
55
---
66

77
import RealtimeLearnMore from "/snippets/realtime-learn-more.mdx";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: "Next.js Realtime CSV Importer"
3+
sidebarTitle: "Realtime CSV Importer"
4+
description: "This example Next.js project demonstrates how to use Trigger.dev Realtime to build a CSV Uploader with progress updates streamed to the frontend."
5+
---
6+
7+
import RealtimeLearnMore from "/snippets/realtime-learn-more.mdx";
8+
9+
## Overview
10+
11+
The frontend is a Next.js app that allows users to upload a CSV file, which is then processed in the background using Trigger.dev tasks. The progress of the task is streamed back to the frontend in real-time using Trigger.dev Realtime.
12+
13+
- A [Next.js](https://nextjs.org/) app with [Trigger.dev](https://trigger.dev/) for the background tasks.
14+
- [UploadThing](https://uploadthing.com/) to handle CSV file uploads
15+
- Trigger.dev [Realtime](https://trigger.dev/launchweek/0/realtime) to stream updates to the frontend.
16+
17+
## GitHub repo
18+
19+
<Card
20+
title="View the Realtime CSV Importer repo"
21+
icon="GitHub"
22+
href="https://github.com/triggerdotdev/examples/blob/main/realtime-csv-importer/README.md"
23+
>
24+
Click here to view the full code for this project in our examples repository on GitHub. You can
25+
fork it and use it as a starting point for your own project.
26+
</Card>
27+
28+
## Video
29+
30+
<video
31+
controls
32+
className="w-full aspect-video"
33+
src="https://github.com/user-attachments/assets/25160343-6663-452c-8a27-819c3fd7b8df"
34+
></video>
35+
36+
## Relevant code
37+
38+
- View the Trigger.dev task code in the [src/trigger/csv.ts](https://github.com/triggerdotdev/examples/blob/main/realtime-csv-importer/src/trigger/csv.ts) file.
39+
- The parent task `csvValidator` downloads the CSV file, parses it, and then splits the rows into multiple batches. It then does a `batch.triggerAndWait` to distribute the work the `handleCSVRow` task.
40+
- The `handleCSVRow` task "simulates" checking the row for a valid email address and then updates the progress of the parent task using `metadata.parent`. See the [Trigger.dev docs](/runs/metadata#parent-and-root-updates) for more information on how to use the `metadata.parent` object.
41+
- The `useRealtimeCSVValidator` hook in the [src/hooks/useRealtimeCSVValidator.ts](https://github.com/triggerdotdev/examples/blob/main/realtime-csv-importer/src/hooks/useRealtimeCSVValidator.ts) file handles the call to `useRealtimeRun` to get the progress of the parent task.
42+
- The `CSVProcessor` component in the [src/components/CSVProcessor.tsx](https://github.com/triggerdotdev/examples/blob/main/realtime-csv-importer/src/components/CSVProcessor.tsx) file handles the file upload and displays the progress bar, and uses the `useRealtimeCSVValidator` hook to get the progress updates.
43+
44+
<RealtimeLearnMore />

docs/guides/example-projects/realtime-fal-ai.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: "Generate an image from a prompt using Fal.ai and Trigger.dev Realtime"
2+
title: "Image generation with Fal.ai and Trigger.dev Realtime"
33
sidebarTitle: "Realtime image gen with Fal.ai"
4-
description: "This example project generates an image from a prompt using Fal.ai and shows the progress of the task on the frontend using Trigger.dev Realtime."
4+
description: "This example Next.js project generates an image from a prompt using Fal.ai and shows the progress of the task on the frontend using Trigger.dev Realtime."
55
---
66

77
import RealtimeLearnMore from "/snippets/realtime-learn-more.mdx";

docs/guides/introduction.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Example projects are full projects with example repos you can fork and use. Thes
4141
| :--------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------- | :-------- | :---------------------------------------------------------------------------------------------------- |
4242
| [Realtime Fal.ai image generation](/guides/example-projects/realtime-fal-ai) | Generate an image from a prompt using Fal.ai and show the progress of the task on the frontend using Realtime. | Next.js | [View the repo](https://github.com/triggerdotdev/examples/tree/main/realtime-fal-ai-image-generation) |
4343
| [Batch LLM Evaluator](/guides/example-projects/batch-llm-evaluator) | Evaluate multiple LLM models and stream the results to the frontend. | Next.js | [View the repo](https://github.com/triggerdotdev/examples/tree/main/batch-llm-evaluator) |
44+
| [Realtime CSV Importer](/guides/example-projects/realtime-csv-importer) | Upload a CSV file and see the progress of the task streamed to the frontend. | Next.js | [View the repo](https://github.com/triggerdotdev/examples/tree/main/realtime-csv-importer) |
4445

4546
## Example tasks
4647

docs/mint.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@
350350
"group": "Example projects",
351351
"pages": [
352352
"guides/example-projects/realtime-fal-ai",
353-
"guides/example-projects/batch-llm-evaluator"
353+
"guides/example-projects/batch-llm-evaluator",
354+
"guides/example-projects/realtime-csv-importer"
354355
]
355356
},
356357
{

0 commit comments

Comments
 (0)