packages/cli-v3/skills/trigger-realtime-and-frontend/SKILL.md
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:
node_modules/@trigger.dev/sdk/skills/trigger-realtime-and-frontend/SKILL.md — run subscriptions, @trigger.dev/react-hooks, streams, frontend triggering, and scoped tokens.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.
CRITICAL: Triggering from the browser with a Public Access Token. The
read token from createPublicToken cannot trigger tasks.
useTaskTrigger("my-task", { accessToken: publicAccessTokenFromCreatePublicToken })auth.createTriggerPublicToken("my-task") and pass that.Token with no scopes. A scopeless token authorizes nothing, so every subscribe 403s.
await auth.createPublicToken()await auth.createPublicToken({ scopes: { read: { runs: ["run_1234"] } } })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.
useRun(runId, { refreshInterval: 1000 }) to track progressuseRealtimeRun(runId, { accessToken }) (no polling, no WebSocket setup)Forgetting "use client". Realtime/trigger hooks cannot run in a server component.
useRealtimeRun"use client"; at the top of any component using these hooks.Shipping payload/output you do not render.
useRealtimeRun(runId, { accessToken }) for a status badge (large payloads over the wire)useRealtimeRun(runId, { accessToken, skipColumns: ["payload", "output"] })Subscribing before the handle exists.
useRealtimeRun(handle, { accessToken: handle?.publicAccessToken }) with no guardenabled: !!handle so it subscribes only once the trigger returns a handle.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).