---
id: api/commands/spread
title: spread | Cypress Documentation
description: Expand an array into multiple arguments in Cypress.
section: api
source_path: docs/api/commands/spread.mdx
version: 204dffbf7fbb64b1fe8343a54ddcd869cc275f1f
updated_at: '2026-05-12T20:33:17.938Z'
---
# spread

Expand an array into multiple arguments.

Identical to [`.then()`](/llm/markdown/api/commands/then.md), but always expects an array-like structure as its subject.

## Syntax

```
.spread(callbackFn).spread(options, callbackFn)
```

### Usage

**Correct Usage**

```
cy.getCookies().spread(() => {}) // Yield all cookies
```

**Incorrect Usage**

```
cy.spread(() => {}) // Errors, cannot be chained off 'cy'cy.clock().spread() // Errors, 'clock' does not yield an array
```

### Arguments

**fn _(Function)_**

Pass a function that expands the array into its arguments.

**options _(Object)_**

Pass in an options object to change the default behavior of `.spread()`.

| Option | Default | Description |
| --- | --- | --- |
| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.spread()` to resolve before [timing out](#Timeouts) |

### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)

*   `.spread()` yields the return value of your callback function.
*   `.spread()` wlll not change the subject if `null` or `undefined` is returned.
*   If the returned values are DOM elements, it is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.spread()`.

## Examples

### Aliased Routes

#### Expand the array of aliased routes

```
cy.intercept('/users/*').as('getUsers')cy.intercept('/activities/*').as('getActivities')cy.intercept('/comments/*').as('getComments')cy.wait(['@getUsers', '@getActivities', '@getComments']).spread(  (getUsers, getActivities, getComments) => {    // each interception is now an individual argument  })
```

### Cookies

#### Expand the array of cookies

```
cy.getCookies().spread((cookie1, cookie2, cookie3) => {  // each cookie is now an individual argument})
```

## Rules

### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)

*   `.spread()` requires being chained off a previous command.
*   `.spread()` requires being chained off a command that yields an array-like structure.

### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)

*   `.spread()` will only run assertions you have chained once, and will not [retry](/llm/markdown/app/core-concepts/retry-ability.md).

### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)

*   `.spread()` can time out waiting for a promise you've returned to resolve.

## Command Log

*   `.spread()` does _not_ log in the Command Log

## History

| Version | Changes |
| --- | --- |
| [0.5.9](/llm/markdown/app/references/changelog.md#0-5-9) | `.spread()` command added |

## See also

*   [`.each()`](/llm/markdown/api/commands/each.md)
*   [`.then()`](/llm/markdown/api/commands/then.md)
