---
id: api/commands/go
title: go | Cypress Documentation
description: >-
  Navigate back or forward to the previous or next URL in the browser's history
  in Cypress.
section: api
source_path: docs/api/commands/go.mdx
version: 7ada28c0cd90e81cf56fd3fc73de6e6d45c16de6
updated_at: '2026-05-13T21:55:41.935Z'
---
# go

Navigate back or forward to the previous or next URL in the browser's history.

## Syntax

```
cy.go(direction)cy.go(direction, options)
```

### Usage

**Correct Usage**

```
cy.go('back')
```

### Arguments

**direction _(String, Number)_**

The direction to navigate.

You can use `back` or `forward` to go one step back or forward. You could also navigate to a specific history position (`-1` goes back one page, `1` goes forward one page, etc).

**options _(Object)_**

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

| Option | Default | Description |
| --- | --- | --- |
| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |
| `timeout` | [`pageLoadTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.go()` to resolve before [timing out](#Timeouts) |

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

*   `cy.go()` yields the `window` object after the page finishes loading.
*   It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the yielded `window` after `cy.go()`.

## Examples

### Direction

#### Go back in browser's history

```
cy.go('back') // equivalent to clicking back button
```

#### Go forward in browser's history

```
cy.go('forward') // equivalent to clicking forward button
```

### Number

#### Go back in browser's history

```
cy.go(-1) // equivalent to clicking back button
```

#### Go forward in browser's history

```
cy.go(1) // equivalent to clicking forward button
```

## Notes

### Refreshing and loading the page

If going forward or back causes a full page refresh, Cypress will wait for the new page to load before moving on to new commands.

Cypress additionally handles situations where a page load was not caused (such as hash routing) and will resolve immediately.

## Rules

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

*   `cy.go()` requires being chained off of `cy`.
*   `cy.go()` requires the response to be `content-type: text/html`.
*   `cy.go()` requires the response code to be `2xx` after following redirects.
*   `cy.go()` requires the load `load` event to eventually fire.

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

*   `cy.go()` will automatically wait for assertions you have chained to pass.

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

*   `cy.go()` can time out waiting for the page to fire its `load` event.
*   `cy.go()` can time out waiting for assertions you've added to pass.

## Command Log

**_Go back in browser's history_**

```
cy.visit('http://localhost:8000/folders').go('back')
```

The commands above will display in the Command Log as:

When clicking on the `go` command within the command log, the console outputs the following:

## See also

*   [`cy.reload()`](/llm/markdown/api/commands/reload.md)
*   [`cy.visit()`](/llm/markdown/api/commands/visit.md)
