Introducing Temporal Support for Mastra Workflows

Your workflows can now run on Temporal with durable, fault-tolerant execution.

Paul ScanlonPaul Scanlon·

May 12, 2026

·

2 min read

Your Mastra workflows can now run on Temporal. The new Temporal integration gives you retries, scheduling, durable state, and execution that survives worker restarts.

Workflow code stays identical. Under the hood, createWorkflow() becomes a Temporal workflow and createStep() becomes a Temporal activity.

Reach for Temporal when your workflows call external APIs, stretch over hours or days, or have to outlive a worker restart. You can self-host it or use the hosted version.

Get started

Install the Temporal packages:

npm install @mastra/temporal @temporalio/client @temporalio/worker @temporalio/envconfig
note

Requires @mastra/core@1.32.0 or later, added in PR #15789.

Running Mastra workflows on Temporal consists of three parts:

  1. A Temporal client instance to convert the workflow functions
  2. An import swap in workflow files
  3. A long-lived worker process to run them

Temporal client instance

Create a Temporal client instance that binds Mastra's createWorkflow and createStep to a Temporal task queue. (typically created at src/mastra/temporal/index.ts)

Import swap

Import createWorkflow and createStep from the Temporal client instance:

// resolves to src/mastra/temporal/index.ts
import { createWorkflow, createStep } from "../temporal";
 
const incrementStep = createStep({
  id: "increment-step"
  //...
});
 
export const incrementWorkflow = createWorkflow({
  id: "increment-workflow"
  // ...
})
  .then(incrementStep)
  .commit();

Worker process

Create a worker process that polls the Temporal task queue and runs your workflows.

Config-wise, both the Temporal instance and worker accept knobs like startToCloseTimeout, maxConcurrentActivityTaskExecutions, and shutdownForceTime — see the Temporal deployment guide for the full list.

@mastra/temporal is still experimental and the API may change between releases. The package README has the current state.

Share:
Paul Scanlon
Paul ScanlonTechnical Product Marketing Manager

Paul Scanlon sits between Developer Education and Product Marketing at Mastra. Previously, he was a Technical Product Marketing Manager at Neon and worked in Developer Relations at Gatsby, where he created educational content and developer experiences.

All articles by Paul Scanlon