---
title: "Reference: Workflow.branch() | Workflows"
description: Documentation for the `Workflow.branch()` method in workflows, which creates conditional branches between steps.
packages:
  - "@mastra/core"
---

# Workflow.branch()

The `.branch()` method creates conditional branches between workflow steps, allowing for different paths to be taken based on the result of a previous step.

## Usage example

```typescript
workflow.branch([
  [async ({ context }) => true, step1],
  [async ({ context }) => false, step2],
]);
```

## Parameters

<PropertiesTable
  content={[
    {
      name: "steps",
      type: "[() => boolean, Step]",
      description:
        "An array of tuples, each containing a condition function and a step to execute if the condition is true",
      isOptional: false,
    },
  ]}
/>

## Returns

<PropertiesTable
  content={[
    {
      name: "workflow",
      type: "NewWorkflow",
      description: "The workflow instance for method chaining",
    },
  ]}
/>

## Related

- [Conditional Branching Logic](/docs/v1/workflows/control-flow#conditional-logic-with-branch)
- [Control Flow](/docs/v1/workflows/control-flow)
