Skip to content

Commit f6af1ef

Browse files
authored
Add a doc describing howto enable and use the API.
1 parent baef611 commit f6af1ef

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

howto.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# How to use the URLPattern API
2+
3+
The URLPattern API is currently available in Chrome 93 and later behind a flag.
4+
5+
1. Download Chrome ([Android](https://play.google.com/store/apps/details?id=com.android.chrome), [Desktop](https://www.google.com/chrome/)).
6+
2. Navigate to `chrome://flags` and enable `Experimental Web Platform features`.
7+
3. Visit a page that uses `URLPattern`, such as the [demo on glitch](https://urlpattern-sw-routing.glitch.me/).
8+
9+
Here is an example of how to use the API:
10+
11+
```javascript
12+
const pattern = new URLPattern({ pathname: '/:product/index.html' });
13+
const result = pattern.exec(someURL);
14+
if (result) {
15+
handleProduct(result.pathname.groups.product);
16+
}
17+
```
18+
19+
More code examples can be found in the [URLPattern documentation](docs/urlpattern.md).

0 commit comments

Comments
 (0)