URLPattern: hash property

Baseline 2025
Newly available

Since September 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Note: This feature is available in Web Workers.

The hash read-only property of the URLPattern interface is a string containing the pattern used to match the fragment part of a URL.

This is the normalized value of the hash pattern passed to the constructor, an inherited value from a baseURL passed to the constructor, or the default value ("*"), which matches any hash.

Value

A string.

Examples

Basic usage

The below example creates a URLPattern object with books/:id for the hash part and logs the property. This pattern matches any fragment that starts with books/ and ends with an arbitrary string identifier.

js
const pattern = new URLPattern("https://example.org#books/:id");
console.log(pattern.hash); // 'books/:id'
console.log(pattern.test("https://example.org#books/123")); // true

Specifications

Specification
URL Pattern
# dom-urlpattern-hash

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
hash
Chrome – Full support
Chrome 95 (Release date: 2021-10-19)
footnote Full support
Edge – Full support
Edge 95 (Release date: 2021-10-21)
footnote Full support
Firefox – Full support
Firefox 142 (Release date: 2025-08-19)
footnote Full support
Opera – Full support
Opera 81 (Release date: 2021-11-04)
footnote Full support
Safari – Full support
Safari 26 (Release date: 2025-09-15)
footnote Full support
Chrome Android – Full support
Chrome Android 95 (Release date: 2021-10-19)
footnote Full support
Firefox for Android – Full support
Firefox for Android 142 (Release date: 2025-08-19)
footnote Full support
Opera Android – Full support
Opera Android 67 (Release date: 2022-01-31)
footnote Full support
Safari on iOS – Full support
Safari on iOS 26 (Release date: 2025-09-15)
footnote Full support
Samsung Internet – Full support
Samsung Internet 17 (Release date: 2022-05-04)
footnote Full support
WebView Android – Full support
WebView Android 95 (Release date: 2021-10-19)
footnote Full support
WebView on iOS – Full support
WebView on iOS 26 (Release date: 2025-09-15)
footnote Full support
Bun – Full support
Bun 1.3.4 (Release date: 2025-12-07)
footnote Full support
Deno – Full support
Deno 1.15 (Release date: 2021-10-12)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support