github molefrog/wouter v3.13.0
v3.13.0 — URLPattern route matching

2 hours ago

Adds an opt-in native URLPattern parser for React and Preact, including nested routes (#576).

import { Router, Route } from "wouter";
import { urlPatternParser } from "wouter/url-pattern";

<Router parser={urlPatternParser}>
  <Route path="/users{/:id}?">
    {(params) => <>User: {params.id ?? "all"}</>}
  </Route>
</Router>;

For Preact, import the adapter from wouter-preact/url-pattern.

  • Requires native URLPattern support. Matching is case-sensitive, distinguishes trailing slashes, and keeps parameter values URL-encoded.
  • The default parser remains unchanged. Complex URLPattern patterns may need explicit TypeScript parameter types.
  • Parser types now accept any compatible exec matcher with optional keys. Code accessing RegExp-specific properties through that return type may need a type adjustment.

Both packages are published as 3.13.0 under the npm latest tag.

Don't miss a new wouter release

NewReleases is sending notifications on new releases.