Files
2025-11-14 09:42:20 +00:00

47 lines
1.5 KiB
Plaintext

---
title: Backend overview
sidebarTitle: Overview
description: Using the Trigger.dev realtime API from your backend code
---
import RealtimeExamplesCards from "/snippets/realtime-examples-cards.mdx";
Use these backend functions to subscribe to runs and streams from your server-side code or other tasks.
## Overview
There are three main categories of functionality:
- **[Subscribe functions](/realtime/backend/subscribe)** - Subscribe to run updates using async iterators
- **[Metadata](/realtime/backend/subscribe#subscribe-to-metadata-updates-from-your-tasks)** - Update and subscribe to run metadata in real-time
- **[Streams](/realtime/backend/streams)** - Read and consume real-time streaming data from your tasks
<Note>
To learn how to emit streams from your tasks, see our [Realtime Streams](/tasks/streams) documentation.
</Note>
## Authentication
All backend functions support both server-side and client-side authentication:
- **Server-side**: Use your API key (automatically handled in tasks)
- **Client-side**: Generate a Public Access Token with appropriate scopes
See our [authentication guide](/realtime/auth) for detailed information on creating and using tokens.
## Quick example
Subscribe to a run:
```ts
import { runs, tasks } from "@trigger.dev/sdk";
// Trigger a task
const handle = await tasks.trigger("my-task", { some: "data" });
// Subscribe to real-time updates
for await (const run of runs.subscribeToRun(handle.id)) {
console.log(`Run ${run.id} status: ${run.status}`);
}
```