Skip to content

Commit

Permalink
Parameter name for wildcard segments.
Browse files Browse the repository at this point in the history
  • Loading branch information
molefrog committed Jan 31, 2024
1 parent 28eae96 commit 8415447
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ projects that use wouter: **[Ultra](https://ultrajs.dev/)**,
- [Wouter API](#wouter-api)
- [The list of methods available](#the-list-of-methods-available)
- [Hooks API](#hooks-api)
- [`useRoute`: the power of HOOKS!](#useroute-the-power-of-hooks)
- [`useRoute`: route matching and parameters](#useroute-route-matching-and-parameters)
- [`useLocation` hook: working with the history](#uselocation-hook-working-with-the-history)
- [Additional navigation parameters](#additional-navigation-parameters)
- [Customizing the location hook](#customizing-the-location-hook)
Expand Down Expand Up @@ -166,7 +166,7 @@ Import from `wouter` module.

## Hooks API

### `useRoute`: route patterns and parameters
### `useRoute`: route matching and parameters

Checks if the current location matches the pattern provided and returns an object with parameters. This is powered by a wonderful [`regexparam`](https://github.com/lukeed/regexparam) library, so all its pattern syntax is fully supported.

Expand Down Expand Up @@ -207,6 +207,13 @@ useRoute("/app*");
useRoute("/orders/*?");
```

The second item in the pair `params` is an object with parameters or null if there was no match. For wildcard segments the parameter name is `"wild"`:

```js
// wildcards, matches "/app", "/app-1", "/app/home"
useRoute("/app*");
```

### `useLocation` hook: working with the history

The low-level navigation in wouter is powered by the `useLocation` hook, which is basically a
Expand Down

0 comments on commit 8415447

Please sign in to comment.