Skip to main content

URLPattern Replaces Custom Route Regexes

URLPattern is a built-in matcher for URL paths and full URLs. new URLPattern({pathname: ‘/users/:id’}).exec(input) returns named groups without hand-rolled regex.It supports wildca…

April 22, 2026 JavaScript chris 1 min read REST API

Article takeaway

URLPattern is a built-in matcher for URL paths and full URLs. new URLPattern({pathname: '/users/:id'}).exec(input) returns named groups without hand-rolled regex.It supports wildca…

URLPattern is a built-in matcher for URL paths and full URLs. new URLPattern({pathname: '/users/:id'}).exec(input) returns named groups without hand-rolled regex.

It supports wildcards, optional segments, and even matching by hostname or protocol. The pattern syntax matches the one used by Workers and other modern routers.

Browser support is in Chrome and Safari; Firefox is shipping it through 2025. Bun and Deno already ship it; useful for tiny routers in service workers and edge functions.

Share X / Twitter LinkedIn

Leave a comment

Related Posts