{
  "doc": {
    "id": "api/commands/hash",
    "title": "hash | Cypress Documentation",
    "description": "Get the current URL hash of the page that is currently active in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/hash.md",
    "version": "e6988a974973e9090ce70406c38cb2b9e0eac9fa",
    "updated_at": "2026-05-15T15:50:22.536Z",
    "headings": [
      {
        "id": "api/commands/hash#hash",
        "text": "hash",
        "level": 1
      },
      {
        "id": "api/commands/hash#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/hash#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/hash#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/hash#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/hash#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/hash#no-args",
        "text": "No Args",
        "level": 3
      },
      {
        "id": "api/commands/hash#assert-that-hash-is-users-1-given-remote-url-http-localhost-8000-app-users-1",
        "text": "Assert that hash is #/users/1 given remote URL: http://localhost:8000/app/#/users/1",
        "level": 4
      },
      {
        "id": "api/commands/hash#assert-that-the-hash-matches-via-regexp",
        "text": "Assert that the hash matches via RegExp",
        "level": 4
      },
      {
        "id": "api/commands/hash#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/hash#requirements-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/hash#assertions-learn-about-assertions",
        "text": "Assertions Learn about assertions",
        "level": 3
      },
      {
        "id": "api/commands/hash#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about timeouts",
        "level": 3
      },
      {
        "id": "api/commands/hash#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/hash#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/hash#syntax",
      "doc_id": "api/commands/hash",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\ncy.hash()cy.hash(options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.hash() // Get the url hash\n```\n\n### Arguments\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.hash()`.\n\n**cy.hash( _options_ )**\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.hash()` to resolve before [timing out](#Timeouts) |\n\n### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   When the current URL contains a hash, `cy.hash()` yields the current URL's hash (including the `#` character).\n*   When the current URL does not contain a hash, `cy.hash()` yields an empty string.\n*   `cy.hash()` is a query, and it is _safe_ to chain further commands.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/hash.json",
      "token_estimate": 175
    },
    {
      "id": "api/commands/hash#arguments",
      "doc_id": "api/commands/hash",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.hash()`.\n\n**cy.hash( _options_ )**\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.hash()` to resolve before [timing out](#Timeouts) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/hash.json",
      "token_estimate": 83
    },
    {
      "id": "api/commands/hash#yields-learn-about-subject-management",
      "doc_id": "api/commands/hash",
      "heading": "Yields Learn about subject management",
      "heading_level": 3,
      "content_markdown": "### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   When the current URL contains a hash, `cy.hash()` yields the current URL's hash (including the `#` character).\n*   When the current URL does not contain a hash, `cy.hash()` yields an empty string.\n*   `cy.hash()` is a query, and it is _safe_ to chain further commands.\n",
      "section": "api",
      "anchors": [
        "yields-learn-about-subject-management"
      ],
      "path": "/llm/json/chunked/api/commands/hash.json",
      "token_estimate": 69
    },
    {
      "id": "api/commands/hash#examples",
      "doc_id": "api/commands/hash",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### No Args\n\n#### Assert that hash is `#/users/1` given remote URL: `http://localhost:8000/app/#/users/1`\n\n```\n// yields #/users/1cy.hash().should('eq', '#/users/1') // => true\n```\n\n#### Assert that the hash matches via RegExp\n\n```\n<ul id=\"users\">  <li>    <a href=\"#/users/8fc45b67-d2e5-465a-b822-b281d9c8e4d1\">Fred</a>  </li></ul>\n```\n\n```\ncy.get('#users li').find('a').click()cy.hash().should('match', /users\\/.+$/) // => true\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/hash.json",
      "token_estimate": 64
    },
    {
      "id": "api/commands/hash#no-args",
      "doc_id": "api/commands/hash",
      "heading": "No Args",
      "heading_level": 3,
      "content_markdown": "### No Args\n\n#### Assert that hash is `#/users/1` given remote URL: `http://localhost:8000/app/#/users/1`\n\n```\n// yields #/users/1cy.hash().should('eq', '#/users/1') // => true\n```\n\n#### Assert that the hash matches via RegExp\n\n```\n<ul id=\"users\">  <li>    <a href=\"#/users/8fc45b67-d2e5-465a-b822-b281d9c8e4d1\">Fred</a>  </li></ul>\n```\n\n```\ncy.get('#users li').find('a').click()cy.hash().should('match', /users\\/.+$/) // => true\n```\n",
      "section": "api",
      "anchors": [
        "no-args"
      ],
      "path": "/llm/json/chunked/api/commands/hash.json",
      "token_estimate": 61
    },
    {
      "id": "api/commands/hash#rules",
      "doc_id": "api/commands/hash",
      "heading": "Rules",
      "heading_level": 2,
      "content_markdown": "## Rules\n\n### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)\n\n*   `cy.hash()` requires being chained off of `cy`.\n\n### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)\n\n*   `cy.hash()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed\n\n### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `cy.hash()` can time out waiting for assertions you've added to pass.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/hash.json",
      "token_estimate": 65
    },
    {
      "id": "api/commands/hash#command-log",
      "doc_id": "api/commands/hash",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Assert that the hash matches `#users/new`_**\n\n```\ncy.hash().should('eq', '#users/new')\n```\n\nThe commands above will display in the Command Log as:\n\nWhen clicking on `hash` within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/hash.json",
      "token_estimate": 48
    }
  ]
}