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

The new Temporal integration can run your Mastra workflows with automatic retries, long-running execution, scheduling, and durable state.

The standard Mastra workflow API remains the same. The integration converts each createWorkflow() into a Temporal workflow, and each createStep() into a Temporal activity.

Temporal is a good fit for workflows that orchestrate external APIs, run for hours or days, or need to survive worker restarts. It can run on your own infrastructure or as a hosted service.

Get started

Install the Temporal packages:

 1npm 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:

 1// resolves to src/mastra/temporal/index.ts
 2import { createWorkflow, createStep } from "../temporal";
 3
 4const incrementStep = createStep({
 5  id: "increment-step"
 6  //...
 7});
 8
 9export const incrementWorkflow = createWorkflow({
10  id: "increment-workflow"
11  // ...
12})
13  .then(incrementStep)
14  .commit();

Worker process

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

Config options

The Temporal instance and worker process can accept additional configuration options including:

  • startToCloseTimeout for per-step timeouts
  • maxConcurrentActivityTaskExecutions for worker concurrency
  • shutdownForceTime for graceful shutdown

For more information and full configuration options, see:

@mastra/temporal is experimental. The API may change between releases. See the package README for 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