trigger-realtime-and-frontend

作成者: triggerdotdev

Trigger.devのクライアント/フロントエンド面:実行をリアルタイムで購読(runs.subscribeToRunおよび@trigger.dev/react-hooksフックのuseRealtimeRun)、メタデータを消費…

npx skills add https://github.com/triggerdotdev/trigger.dev --skill trigger-realtime-and-frontend

Realtime and Frontend

The full, version-pinned reference ships inside your installed @trigger.dev/sdk. Read it before writing code — it always matches the SDK version in this project, so it never drifts:

  • Skill: node_modules/@trigger.dev/sdk/skills/trigger-realtime-and-frontend/SKILL.md — run subscriptions, @trigger.dev/react-hooks, streams, frontend triggering, and scoped tokens.
  • Docs: the full, version-pinned docs ship bundled at node_modules/@trigger.dev/sdk/docs/realtime/; the skill above lists the exact pages it draws from in its sources: frontmatter. Grep for a hook, e.g. grep -rl "useRealtimeRun" node_modules/@trigger.dev/sdk/docs/.

If those paths don't exist, @trigger.dev/sdk isn't installed yet — install it first. In a non-hoisted layout, resolve the package with node -p "require.resolve('@trigger.dev/sdk/package.json')" and read skills/ + docs/ beside it.

Common mistakes

  1. CRITICAL: Triggering from the browser with a Public Access Token. The read token from createPublicToken cannot trigger tasks.

    • Wrong: useTaskTrigger("my-task", { accessToken: publicAccessTokenFromCreatePublicToken })
    • Correct: mint a single-use Trigger Token with auth.createTriggerPublicToken("my-task") and pass that.
  2. Token with no scopes. A scopeless token authorizes nothing, so every subscribe 403s.

    • Wrong: await auth.createPublicToken()
    • Correct: await auth.createPublicToken({ scopes: { read: { runs: ["run_1234"] } } })
  3. Polling with useRun/SWR for live updates. useRun is the SWR-based management-API hook (not recommended for live state); set refreshInterval: 0 to stop polling if you do use it.

    • Wrong: useRun(runId, { refreshInterval: 1000 }) to track progress
    • Correct: useRealtimeRun(runId, { accessToken }) (no polling, no WebSocket setup)
  4. Forgetting "use client". Realtime/trigger hooks cannot run in a server component.

    • Wrong: a Next.js App Router server component using useRealtimeRun
    • Correct: put "use client"; at the top of any component using these hooks.
  5. Shipping payload/output you do not render.

    • Wrong: useRealtimeRun(runId, { accessToken }) for a status badge (large payloads over the wire)
    • Correct: useRealtimeRun(runId, { accessToken, skipColumns: ["payload", "output"] })
  6. Subscribing before the handle exists.

    • Wrong: useRealtimeRun(handle, { accessToken: handle?.publicAccessToken }) with no guard
    • Correct: add enabled: !!handle so it subscribes only once the trigger returns a handle.

References

Sibling skills: trigger-authoring-tasks (the task side: streams.define(), metadata.set(), wait.createToken), trigger-authoring-chat-agent and trigger-chat-agent-advanced (chat agents build on these realtime streams).

triggerdotdevのその他のスキル

trigger-dev-tasks
triggerdotdev
このスキルは、Trigger.devのバックグラウンドタスクやワークフローの作成、設計、最適化に使用します。信頼性の高い非同期タスクの作成やAIの実装などが含まれます。
official
trigger-authoring-chat-agent
triggerdotdev
@trigger.dev/sdk/ai の chat.agent を使用して、永続的なAIチャットエージェントを作成・実行します:ターンごとの実行ループ、...chat.toStreamTextOptions() を必ずスプレッドする理由…
official
trigger-agents
triggerdotdev
Trigger.devを使用したAIエージェントパターン - オーケストレーション、並列化、ルーティング、評価者最適化、ヒューマンインザループ。LLMを活用したタスクを構築する際に使用します…
official
trigger-config
triggerdotdev
trigger.config.tsを使用してTrigger.devプロジェクトを設定します。Prisma、Playwright、FFmpeg、Pythonのビルド拡張を設定する場合や、デプロイをカスタマイズする場合に使用します…
official
trigger-cost-savings
triggerdotdev
Trigger.devのタスク、スケジュール、実行を分析し、コスト最適化の機会を見つけます。支出削減、コスト最適化、使用状況監査、適正化などを求められた際に使用します。
official
trigger-realtime
triggerdotdev
Trigger.devのタスク実行をフロントエンドとバックエンドからリアルタイムで購読します。進捗インジケーター、ライブダッシュボード、ストリーミングAI/LLM応答などを構築する際に使用します。
official
trigger-setup
triggerdotdev
プロジェクトにTrigger.devをセットアップします。初めてTrigger.devを追加するとき、trigger.config.tsを作成するとき、またはtriggerディレクトリを初期化するときに使用します。
official
trigger-tasks
triggerdotdev
Trigger.devを使用してAIエージェント、ワークフロー、耐久性のあるバックグラウンドタスクを構築します。タスクの作成、ジョブのトリガー、リトライ処理、cronジョブのスケジュール設定などに使用します。
official