# Cypress Documentation
# Source: https://raw.githubusercontent.com/cypress-io/cypress-documentation/main/docs/api/commands/getalllocalstorage.mdx
# Path: docs/api/commands/getalllocalstorage.mdx

---
title: 'getAllLocalStorage | Cypress Documentation'
description: Get localStorage data for all origins with which the test has interacted in Cypress.
sidebar_label: getAllLocalStorage
---

<ProductHeading product="app" />

# getAllLocalStorage

Get
[`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage)
data for all origins with which the test has interacted.

## Syntax

```javascript
cy.getAllLocalStorage()
cy.getAllLocalStorage(options)
```

### Usage

<Icon name="check-circle" color="green" /> **Correct Usage**

```javascript
cy.getAllLocalStorage()
```

### Arguments

<Icon name="angle-right" /> **options _(Object)_**

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

| Option | Default | Description                                                                         |
| ------ | ------- | ----------------------------------------------------------------------------------- |
| `log`  | `true`  | Displays the command in the [Command log](/app/core-concepts/open-mode#Command-Log) |

<HeaderYields />

`cy.getAllLocalStorage()` yields an object where the keys are origins and the
values are key-value pairs of `localStorage` data.

For example, if `key1` is set to `value1` on `https://example.cypress.io` and
`key2` is set to `value2` on `https://www.cypress-dx.com`,
`cy.getAllLocalStorage()` will yield:

```js
{
  'https://example.cypress.io': {
    key1: 'value1',
  },
  'https://www.cypress-dx.com': {
    key2: 'value2',
  },
}
```

## Examples

### Get all localStorage

```javascript
cy.visit('https://example.cypress.io', {
  onBeforeLoad(win) {
    win.localStorage.setItem('key', 'value')
  },
})

cy.getAllLocalStorage().then((result) => {
  expect(result).to.deep.equal({
    'https://example.cypress.io': {
      key: 'value',
    },
  })
})
```

## Rules

<HeaderRequirements />

- `cy.getAllLocalStorage()` requires being chained off of `cy`.

<HeaderAssertions />

- `cy.getAllLocalStorage()` will only run assertions you have chained once, and
  will not [retry](/app/core-concepts/retry-ability).

<HeaderTimeouts />

- `cy.getAllLocalStorage()` cannot time out.

## See also

- [`cy.clearAllLocalStorage()`](/api/commands/clearalllocalstorage)
- [`cy.clearAllSessionStorage()`](/api/commands/clearallsessionstorage)
- [`cy.clearCookies()`](/api/commands/clearcookies)
- [`cy.clearLocalStorage()`](/api/commands/clearlocalstorage)
- [`cy.getAllSessionStorage()`](/api/commands/getallsessionstorage)