-
Add
Matcher
andMatchResult
interfaces. These are new public APIs for matching sets of patterns. -
Add
RegExpMatcher
andTrieMatcher
concrete implementations of theMatcher
interfaceRegExpMatcher
is a simple array-based matcher that compiles route patterns to regular expressions.TrieMatcher
is a trie-based matcher optimized for large route sets and long-running server applications.
import { TrieMatcher } from '@remix-run/route-pattern' let matcher = new TrieMatcher<{ name: string }>() matcher.add('users/:id', { name: 'user' }) matcher.add('posts/:id', { name: 'post' }) let match = matcher.match('https://example.com/users/123') // { data: { name: 'user' }, params: { id: '123' }, url: ... }