Repository navigation
What's the best way to integrate trigger.dev in NX monorepo #1279
Replies: 1 comment
|
An Nx monorepo works well if you treat Trigger.dev as one dedicated workspace/package, rather than starting a separate Trigger project inside each Next.js app. Suggested layout: apps/trigger/ Keep @trigger.dev/sdk and @trigger.dev/build in the Trigger workspace. Put the task definitions there, and have the Next.js apps trigger them only from server-side code. Use one Trigger project with separate DEV, STAGING, and PROD environments when the apps share the same lifecycle and permissions. Use separate Trigger projects only when the apps need independent ownership, secrets, or deployment lifecycles. For deployment, set the GitHub integration's config path to apps/trigger/trigger.config.ts. If the workspace needs a custom install or pre-build step, configure those in the same integration settings. Trigger.dev explicitly supports this monorepo setup. Locally, run trigger dev and trigger deploy from the workspace that owns trigger.config.ts, or delegate those commands through an Nx target so the correct package dependencies and tsconfig are used. Give every task a unique namespace such as billing.send-invoice or media.generate-preview to avoid collisions. Keep TRIGGER_SECRET_KEY in server-only environment variables; never expose it to the browser. If multiple developers need concurrent local sessions, recent Trigger.dev versions also support isolated dev branches. References:
|
Uh oh!
There was an error while loading. Please reload this page.
I have an NX monorepo with 3 next.js apps and I want to add trigger.dev in my monorepo
What's the best way to integrate it?
All reactions