trigger-realtime-and-frontend

Superfície do cliente/frontend do Trigger.dev: inscreva-se em execuções em tempo real (runs.subscribeToRun e o hook useRealtimeRun do @trigger.dev/react-hooks), consuma metadados…

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).

Mais skills de triggerdotdev

trigger-dev-tasks
triggerdotdev
Use esta habilidade ao escrever, projetar ou otimizar tarefas e fluxos de trabalho em segundo plano do Trigger.dev. Isso inclui criar tarefas assíncronas confiáveis, implementar IA…
official
trigger-authoring-chat-agent
triggerdotdev
Crie e execute um agente de chat de IA durável com chat.agent do @trigger.dev/sdk/ai: o loop de execução por turno, por que você DEVE espalhar ...chat.toStreamTextOptions()…
official
trigger-agents
triggerdotdev
Padrões de agente de IA com Trigger.dev - orquestração, paralelização, roteamento, avaliador-otimizador e humano-no-loop. Use ao construir tarefas baseadas em LLM…
official
trigger-config
triggerdotdev
Configure projetos Trigger.dev com trigger.config.ts. Use ao configurar extensões de build para Prisma, Playwright, FFmpeg, Python ou personalizar implantação…
official
trigger-cost-savings
triggerdotdev
Analise tarefas, cronogramas e execuções do Trigger.dev em busca de oportunidades de otimização de custos. Use quando solicitado a reduzir gastos, otimizar custos, auditar uso, ajustar capacidade…
official
trigger-realtime
triggerdotdev
Inscreva-se nas execuções de tarefas do Trigger.dev em tempo real a partir do frontend e backend. Use ao construir indicadores de progresso, painéis ao vivo, respostas de streaming de IA/LLM,…
official
trigger-setup
triggerdotdev
Configure o Trigger.dev no seu projeto. Use ao adicionar o Trigger.dev pela primeira vez, criar o trigger.config.ts ou inicializar o diretório trigger.
official
trigger-tasks
triggerdotdev
Construa agentes de IA, fluxos de trabalho e tarefas de segundo plano duráveis com Trigger.dev. Use ao criar tarefas, acionar jobs, lidar com novas tentativas, agendar tarefas cron, ou…
official