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
URLPatternsupport. 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.
Parsertypes now accept any compatibleexecmatcher with optionalkeys. 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.