stack-directus-nextjs-trigger
Directus + Next.js + Trigger.dev architecture plugin. How Directus (content, files, access), a Next.js App Router frontend and self-hosted Trigger.dev (durable and scheduled work) fit together: who holds which token, how the cache is invalidated, how a Directus change reaches a task and the result reaches the page, who owns the session, and a production checklist. Tool knowledge comes from its dependencies.
v3.0.5Updated
- stack
- directus-nextjs-trigger
- architecture
- agents-store
- directus
- nextjs
- trigger.dev
- background-jobs
- scheduled-tasks
- self-hosted
- durable-execution
- app-router
Install
Pick your agent for the steps.
Install on Claude Code
1.Add the marketplace
/plugin marketplace add Agents-Store/claude-plugins2.Install the plugin
/plugin install stack-directus-nextjs-trigger@agents-store-claude-pluginsType it inside Claude Code.
Install on GitHub Copilot CLI
1.Add the marketplace
copilot plugin marketplace add Agents-Store/claude-plugins2.Install the plugin
copilot plugin install stack-directus-nextjs-trigger@agents-store-claude-plugins
GitHub Copilot CLI does not receive: commands, agents.
Install on Cursor
1.Manual install
Cursor has no install command for a single plugin. Copy the plugin's folder from its place in the mirror on GitHub into the place Cursor reads plugins from.
Cursor’s plugin documentation now lives at docs.grok.com (cursor.com/docs/plugins redirects there). Plugins come from its marketplace, a team marketplace or a local folder.
Install on Codex
1.Add the marketplace
codex plugin marketplace add Agents-Store/codex-plugins2.Install the plugin
codex plugin add stack-directus-nextjs-trigger@agents-store-codex-plugins
Codex does not receive: commands, agents.
Install on Gemini CLI
1.Clone the mirror
git clone https://github.com/Agents-Store/gemini-extensions2.Install the plugin
gemini extensions link ./gemini-extensions/stack-directus-nextjs-triggerRun it from the folder you cloned into.
Consumer access to Gemini CLI ended on 2026-06-18. This target serves enterprise Gemini Code Assist; Antigravity is the consumer successor.
Install on Antigravity
1.Clone the mirror
git clone https://github.com/Agents-Store/antigravity-skills2.Install the plugin
agy plugin install ./antigravity-skills/stack-directus-nextjs-triggerRun it from the folder you cloned into.
Antigravity does not receive: commands.
Install on Kimi Code
1.Clone the mirror
git clone https://github.com/Agents-Store/kimi-plugins2.Install the plugin
/plugins install ./kimi-plugins/stack-directus-nextjs-triggerRun it from the folder you cloned into, and type it inside Kimi Code.
Kimi Code does not receive: commands, agents, hooks, MCP servers.
Install on Devin
1.Install the plugin
devin plugins install Agents-Store/devin-plugins#stack-directus-nextjs-trigger
Devin does not receive: commands, agents, hooks, MCP servers.
Install on Hermes Agent
1.Install the plugin
hermes plugins install Agents-Store/hermes-plugins/stack-directus-nextjs-trigger
Hermes Agent does not receive: commands, agents, hooks, MCP servers.
Install on OpenCode
1.Manual install
OpenCode has no install command for a single plugin. Copy the plugin's folder from its place in the mirror on GitHub into the place OpenCode reads plugins from.
OpenCode does not receive: hooks.
Install on Pi
1.Manual install
Pi has no install command for a single plugin. Copy the plugin's folder from its place in the mirror on GitHub into the place Pi reads plugins from.
Pi does not receive: commands, agents, hooks, MCP servers.
Install on OpenClaw
1.Clone the mirror
git clone https://github.com/Agents-Store/openclaw-generated-plugins2.Install the plugin
openclaw plugins install ./openclaw-generated-plugins/stack-directus-nextjs-triggerRun it from the folder you cloned into.
OpenClaw does not receive: commands, agents, hooks, MCP servers.
Install on Agent Plugins 1.0
1.Manual install
Agent Plugins 1.0 has no install command for a single plugin. Copy the plugin's folder from its place in the mirror on GitHub into the place Agent Plugins 1.0 reads plugins from.
Agent Plugins 1.0 does not receive: commands, agents, hooks.
What is inside
Skills (8)
- authentication
This skill should be used when the user wants to "add authentication to Directus + Next.js", "implement Directus login in Next.js", "use NextAuth with Directus", "use Better Auth with Directus", "protect Next.js pages with Directus auth", "choose an auth approach for Directus and Next.js", "decide who owns the session", "act as the signed-in user inside a trigger.dev task", or needs to decide who owns the end-user session and the tokens across Directus and Next.js.
- background-tasks
This skill should be used when the user wants to "offload work to trigger.dev from next.js", "run a background job from a server action", "trigger a task from a route handler", "delegate slow work to trigger.dev", "decide what runs in a Server Action and what in a task", "show a task's progress in next.js", "give the browser a token for a trigger.dev run", "keep task environment variables apart from next.js", "fix a TRIGGER_SECRET_KEY build error", or needs the rules where a Next.js App Router app hands work to Trigger.dev and gets the result back.
- deployment
This skill should be used when the user wants to "run the Directus Next.js Trigger.dev stack locally", "deploy trigger.dev tasks next to a Next.js app", "set environment variables for trigger.dev tasks", "configure content-change webhooks with trigger.dev", "revalidate the site when a task changes Directus content", "CI/CD for trigger tasks", "production checklist for directus + nextjs + trigger.dev", or needs the pipelines that connect the three services and the checks before production. For platform-specific hosting (Vercel, Dokploy, etc.), see the respective deployment plugin.
- directus-to-nextjs
This skill should be used when the user wants to "fetch Directus data in Next.js", "display Directus content in Next.js pages", "render Directus images in Next.js", "use Directus SDK with Server Components", "create Next.js pages from Directus collections", "add TypeScript types for Directus", "cache Directus data in Next.js", "revalidate after Directus content changes", "fix 403 on Directus images", or needs the rules where Directus data meets Next.js rendering: who holds the token, what is cached, how files are served, and how types follow the schema.
- directus-to-trigger
This skill should be used when the user wants to "trigger a task from a directus flow", "run a background task when a directus item is created or updated", "forward directus webhooks to trigger.dev", "process directus items asynchronously", "build a directus flow to next.js to trigger pipeline", "have a task write back to directus", "stop a directus flow and task from looping", "read and write directus from a trigger.dev task", or needs the pattern for wiring Directus Flow events through Next.js into Trigger.dev tasks and back.
- examples
End-to-end scenario walkthroughs for the Directus + Next.js + Trigger.dev stack. This skill should be used when the user asks for "directus nextjs trigger.dev examples", "how to build a blog with directus + next.js", "ai enrichment pipeline example", "scheduled data sync example", "show me a complete example with background tasks", or needs implementation references for common application types on this stack.
- full-feature
This skill should be used when the user wants to "build a complete feature with directus nextjs and trigger.dev", "create an end-to-end feature with background tasks", "implement a full crud feature with async processing", "build a new section of the site that uses background jobs", "add a page backed by directus with a background task", or needs a step-by-step recipe for building features that span Directus, Next.js, and Trigger.dev.
- init-project
This skill should be used when the user asks to "set up Directus + Next.js + Trigger.dev project", "initialize directus nextjs trigger.dev stack", "bootstrap the 3-service stack", "configure directus next.js and trigger.dev together", "connect trigger.dev to a directus nextjs app", "scaffold stack with background tasks", "start a new project with background jobs", or needs to set up environment variables, versions and verify connections for the Directus + Next.js + Trigger.dev stack.
Agents (1)
- stack-orchestrator
Use this agent when the user needs help coordinating work across Directus, Next.js, and Trigger.dev: building pages that display Directus content, deciding who owns the user session, offloading slow work to background tasks, wiring a Directus change to a task, defining scheduled jobs, or implementing features that span all three services. <example> Context: User wants to build a page that displays Directus content user: "Build a blog listing page that fetches posts from Directus and displays them with images" assistant: "I'll use the stack-orchestrator agent to build the blog page with tagged Directus reads and image handling." <commentary> The feature needs Directus SDK reads in a Next.js Server Component with the cache tags and image rules of the stack: it spans the Data and Interface layers. </commentary> </example> <example> Context: User wants to add a background enrichment pipeline user: "When an article is created in Directus, automatically enrich it with AI-generated tags and a summary" assistant: "I'll use the stack-orchestrator agent to wire the Directus Flow, the Next.js receiver, the Trigger.dev task and the write-back." <commentary> The feature spans all three services: a Flow with a loop guard, a receiver that starts a debounced task, a task with its own Directus token, and the page refresh. This is what the orchestrator exists for. </commentary> </example> <example> Context: User wants a scheduled data sync user: "Pull currency rates from an external API every day at 2am and store them in Directus" assistant: "I'll use the stack-orchestrator agent to define a scheduled Trigger.dev task that upserts into Directus and refreshes the dashboard." <commentary> Needs a declarative schedule, the task-side Directus client, an idempotent upsert and the revalidation path; the schedule rules come from the trigger-dev plugin. </commentary> </example> <example> Context: User hits a build failure with Trigger.dev user: "My CI build is failing with 'You need to set the TRIGGER_SECRET_KEY environment variable' on a route that calls tasks.trigger()" assistant: "I'll use the stack-orchestrator agent to find where the trigger runs at build time." <commentary> The SDK reads the environment on the first call, not on import: a trigger at module level or during prerendering is the cause. The background-tasks skill has the rule. </commentary> </example> <example> Context: User wants to add authentication user: "Set up user login using Directus authentication and NextAuth" assistant: "I'll use the stack-orchestrator agent to decide who owns the session and wire the matching authentication path." <commentary> Authentication spans Directus (user store, token management) and Next.js (session library, proxy); the orchestrator decides who owns the session and coordinates both sides, and keeps user tokens out of tasks. </commentary> </example> <example> Context: User wants to deploy the full stack user: "Deploy my Next.js app and set up auto-rebuild when Directus content changes, and deploy my Trigger.dev tasks" assistant: "I'll use the stack-orchestrator agent to configure the pipelines and the environment variables across all three services." <commentary> Deployment involves the Next.js host variables, the Directus Flows and their secrets, the Trigger.dev environment, and a separate task deploy with a pinned CLI. </commentary> </example> <example> Context: User encounters a cross-service issue user: "My Directus images aren't loading in production" assistant: "I'll use the stack-orchestrator agent to diagnose the image loading issue across Directus permissions, Next.js image config, and hosting settings." <commentary> Cross-service debugging requires understanding Directus file permissions, the images block of next.config.ts, and environment variables. </commentary> </example>
MCP servers (2)
- directus http
- trigger-dev stdio
README
Directus + Next.js + Trigger.dev architecture plugin for Agents Store. It describes how Directus (content, files, access), a Next.js App Router frontend and self-hosted Trigger.dev (durable and scheduled work) fit together: who holds which token, how the cache is invalidated when content or a task changes it, how a Directus change reaches a task and the result reaches the page, who owns the user session, and what to check before production. It names its parts in dependencies; what one tool does and how to drive it is taught by that tool's own plugin.
Architecture
| Layer | Service | Role |
|---|---|---|
| Data | Directus | Content, REST API, file storage, users and policies, Flows |
| Interface + Logic | Next.js | App Router, Server Components, Server Actions, Route Handlers |
| Work | Trigger.dev (self-hosted) | Durable tasks: retries, schedules, AI calls, long-running and bulk work, on its own workers |
Next.js keeps the synchronous work (rendering, actions, webhook receivers). Anything slow, flaky or scheduled leaves it as a task that retries, can be observed, and writes its result back to Directus.
The boundaries between them are what this plugin owns:
| Boundary | Rule |
|---|---|
| Token | The Next.js server holds a service token of a dedicated Directus user; a task holds the token of its own Directus user; the browser holds nothing of Directus |
| Cache | Every Directus read is tagged with its collection; a Directus Flow (or a task) expires the tag through a Route Handler |
| Assets | A file URL never carries a token: public files, or a server route that adds the token |
| Types | types/directus.ts follows the Directus schema, the tasks import it too, and tsc is the drift check |
| Session | One owner of the end-user session, chosen once (see authentication) |
| Task payload | Ids and requestedBy, never a token and never a copy of the item |
| Task environment | A task sees only the variables of its Trigger.dev project, never the Next.js host's |
| Browser to task | Only the run-scoped public token and the server address; never TRIGGER_SECRET_KEY |
Deployment of the Next.js app is handled by a separate plugin (for example dokploy-dev, vercel-dev); tasks deploy separately with the Trigger.dev CLI.
Dependencies
Declared in plugin.json and installed together with the stack. They hold the tool-level knowledge:
| Plugin | Teaches |
|---|---|
directus-dev | Directus MCP tools, REST API, @directus/sdk (sdk-patterns, including server-side use), local Docker Compose (docker-local-dev), Flows (flow-automation, including the Flow that sends item keys to a worker), schema design |
nextjs-dev | App Router, data fetching and caching (data-fetching), authentication (auth-patterns), proxy.ts, images, Cache Components |
trigger-dev | Tasks, retries, queues, debounce and idempotency (task-development), schedules (scheduled-tasks), tokens and hooks for the browser (realtime), deploys and CI (deployment), CLI, MCP tools, self-hosted infrastructure |
nextjs-provision (shadcn/ui setup) is optional: install it separately if you want it. Pick the plugin that matches your hosting for deployment (dokploy-dev, vercel-dev).
More from trigger-dev that fits this stack once the basics work: a human approval step in a pipeline (wait.createToken plus a status field in Directus, completed from the browser with useWaitToken; realtime), AI chat agents as tasks (ai-chat-agents), and run and cost analysis with TRQL (observability).
Prerequisites
- Directus 12 (MCP needs 11.12 or later and is switched on in Settings → AI)
- Next.js 16,
next@^16.3.8 - Node.js 22 or later (
@directus/sdk26 requires it) - A self-hosted Trigger.dev 4.x server (webapp and supervisor running);
@trigger.dev/sdk,@trigger.dev/react-hooksand thetrigger.devCLI at the version of the server - Docker, for a local Directus
Installation
claude plugin install stack-directus-nextjs-trigger@agents-store-claude-plugins
The three technology plugins above come with it. Copies installed under the plugin's former name move to this one through the marketplace renames map; update enabledPlugins entries and any skill reference that still uses the old name (see LEARNINGS.md).
MCP Servers
This plugin's .mcp.json connects Claude to Directus and to Trigger.dev. Tools are named mcp__plugin_stack-directus-nextjs-trigger_directus__<tool> and mcp__plugin_stack-directus-nextjs-trigger_trigger-dev__<tool>.
| Server | Transport | Address |
|---|---|---|
directus | HTTP | ${NEXT_PUBLIC_DIRECTUS_URL}/mcp with Bearer ${DIRECTUS_ADMIN_TOKEN} |
trigger-dev | stdio | npx trigger.dev@${TRIGGER_CLI_VERSION:-latest} mcp --dev-only --project-ref ${TRIGGER_PROJECT_REF}, with TRIGGER_ACCESS_TOKEN and TRIGGER_API_URL |
- Directus MCP acts with the permissions of the token's user, so a token of a dedicated user with a narrow policy also narrows what the model can change.
- Trigger.dev MCP runs with
--dev-only: every tool that takes an environment answers only fordev, anddeployand the deploy and preview-branch listings are refused. It keepstrigger_task, so the agent can start a test run. Drop the flag to reach production, or add--readonlyto hide the write tools (trigger_taskincluded). - Set
TRIGGER_CLI_VERSIONto the version of your server so the MCP server runs the matching CLI; the default islatest. ${VAR}in.mcp.jsonis expanded from the environment Claude Code runs in (your shell, or theenvblock of.claude/settings.local.json), not from.env.local.
Environment Variables
Copy templates/.env.example to your project root as .env.local (Next.js), and templates/.env.trigger.example to .env.trigger.local (the tasks, for trigger dev):
| Variable | Purpose | Client-side |
|---|---|---|
NEXT_PUBLIC_DIRECTUS_URL | Directus address | Yes |
DIRECTUS_ADMIN_TOKEN | Static token of a dedicated Directus user (the name is historical; an administrator token is for local development only) | No |
DIRECTUS_URL, DIRECTUS_TOKEN, NEXT_PUBLIC_CMS_URL | The names the directus-dev and nextjs-dev recipes read. In .env.local they expand to the two variables above (DIRECTUS_URL=${NEXT_PUBLIC_DIRECTUS_URL}, DIRECTUS_TOKEN=${DIRECTUS_ADMIN_TOKEN}, NEXT_PUBLIC_CMS_URL=${NEXT_PUBLIC_DIRECTUS_URL}); without them the NextAuth login calls undefined/auth/login and the images config fails | NEXT_PUBLIC_CMS_URL: yes |
NEXT_PUBLIC_SITE_URL | Address of this site (RSS, metadata, the call a task makes to /api/revalidate) | Yes |
NEXTAUTH_URL, NEXTAUTH_SECRET | NextAuth (NextAuth path only) | No |
REVALIDATION_SECRET | Shared secret for /api/revalidate, sent in a header by a Directus Flow and by tasks that call the route | No |
DIRECTUS_WEBHOOK_SECRET | Shared secret for /api/directus-webhook/*, sent in a header by the Flow that starts a task. A different value from REVALIDATION_SECRET | No |
PUBLIC_ASSET_FOLDER_ID | Directus folder whose files the asset proxy may serve (proxy path only) | No |
TRIGGER_API_URL | Address of the self-hosted server. Set wherever tasks.trigger() runs: without it the SDK falls back to Trigger.dev Cloud | No |
TRIGGER_SECRET_KEY | Environment secret key (tr_dev_... for dev). The SDK in the Next.js server triggers tasks with it | No |
TRIGGER_ACCESS_TOKEN | Personal Access Token (tr_pat_...) for the MCP server and trigger deploy | No |
TRIGGER_PROJECT_REF | Project ref (proj_...) | No |
NEXT_PUBLIC_TRIGGER_API_URL | The server address for browser hooks (baseURL); expands to ${TRIGGER_API_URL} in .env.local | Yes |
TRIGGER_CLI_VERSION | Optional: the version of your server, for the MCP server's CLI | No |
Two Trigger.dev credentials.
TRIGGER_SECRET_KEYis the environment secret key the SDK uses to trigger tasks.TRIGGER_ACCESS_TOKENis a Personal Access Token (dashboard → Account → Personal Access Tokens) for the MCP server and the CLI: the MCP server's account-level tools reject environment keys. The PAT's user must be a member of the organization that ownsTRIGGER_PROJECT_REF.
Tasks have their own variables.
.env.trigger.local(fortrigger dev) and the Trigger.dev project environment (deployed) holdDIRECTUS_URL,DIRECTUS_TOKEN(the task user's token), and any third-party key. The Trigger.dev CLI loads dotenv files but does not expand${VAR}, so the.env.localaliases would reach a task as literal text.
Skills
| Skill | Description |
|---|---|
init-project | Versions, environment, dependencies, client and types, the Trigger.dev project, verification of the three connections |
directus-to-nextjs | The Directus to Next.js boundary: token, cache, assets, types |
authentication | Who owns the user session and the tokens; three paths; why a user's token never goes into a task |
deployment | Local run, the four pipelines, environment variables per service, task deploys, production checklist |
background-tasks | The Next.js to Trigger.dev boundary: what to offload, what crosses, starting a task from an action, handing the run to the browser, closing the loop |
directus-to-trigger | Directus Flow to receiver to task to write-back: the Flow's values, the receiver, the task-side client, loop guards |
full-feature | Step-by-step recipe for building a feature across the three layers |
examples | Scenario walkthroughs (blog, product catalog, AI enrichment pipeline, scheduled data sync) |
Agent
stack-orchestrator: Coordinates work across Directus, Next.js and Trigger.dev: content pages, the session, revalidation, tasks started by users, Directus changes or the clock, and cross-service debugging.
Source
- Source on GitHub
- Mirror: Agents-Store/claude-plugins
- Mirror: Agents-Store/cursor-plugins
- Mirror: Agents-Store/codex-plugins
- Mirror: Agents-Store/gemini-extensions
- Mirror: Agents-Store/antigravity-skills
- Mirror: Agents-Store/kimi-plugins
- Mirror: Agents-Store/devin-plugins
- Mirror: Agents-Store/hermes-plugins
- Mirror: Agents-Store/opencode-plugins
- Mirror: Agents-Store/pi-extensions
- Mirror: Agents-Store/openclaw-generated-plugins
- Mirror: Agents-Store/agentplugins