Skip to content

fix(shared): suggest :path* subtree form in createRouteMatcher path types#9057

Open
jacekradko wants to merge 1 commit into
mainfrom
jacek/path-matcher-path-star
Open

fix(shared): suggest :path* subtree form in createRouteMatcher path types#9057
jacekradko wants to merge 1 commit into
mainfrom
jacek/path-matcher-path-star

Conversation

@jacekradko

@jacekradko jacekradko commented Jul 1, 2026

Copy link
Copy Markdown
Member

createRouteMatcher's route-type suggestions now offer /dashboard/:path* instead of /dashboard(.*). (.*) also matches sibling routes like /dashboardxyz; :path* matches only /dashboard and its path-segment subtree. It's a type-level suggestion only (the param is Autocomplete-wrapped), so existing (.*) patterns keep type-checking and there's no runtime change.

Worth a look: the root special-case. WithPathPatternWildcard<'/'> resolves to /:path*, not the naive //:path* (which the vendored path-to-regexp 6.x matches as only /, not everything). I verified /dashboard/:path*, /:path*, and legacy (.*) against the vendored matcher, and @clerk/nextjs typechecks clean against it.

Scoped to the type on purpose: the ['/foo', '/bar(.*)'] JSDoc examples in nextjs/astro/nuxt are left as-is here and can be aligned in a follow-up. The docs are moving to recommend :path* too.

Summary by CodeRabbit

  • New Features
    • Route autocomplete suggestions now prefer the :path* wildcard format for nested paths, making suggested routes more consistent and easier to read.
  • Bug Fixes
    • Improved wildcard route handling for the root path so suggestions avoid invalid double-slash patterns.
    • Existing (.*) route patterns continue to work as before.

…ypes

WithPathPatternWildcard now suggests `/dashboard/:path*` instead of `/dashboard(.*)`.
The `:path*` form matches on path-segment boundaries, so it covers `/dashboard` and its
subtree without also matching sibling routes like `/dashboardxyz`. Root is special-cased
to `/:path*` to avoid a malformed `//:path*`. Backward compatible: the param is
Autocomplete-wrapped, so existing `(.*)` patterns still type-check, and there is no runtime change.
@changeset-bot

changeset-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 42cecb9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@clerk/shared Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/chrome-extension Patch
@clerk/clerk-js Patch
@clerk/electron Patch
@clerk/expo-passkeys Patch
@clerk/expo Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/headless Patch
@clerk/hono Patch
@clerk/localizations Patch
@clerk/msw Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/react Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/ui Patch
@clerk/vue Patch
@clerk/swingset Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jul 1, 2026 3:23am
swingset Ready Ready Preview, Comment Jul 1, 2026 3:23am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: fa1c58cd-2401-4fd4-812e-f6a5400ac431

📥 Commits

Reviewing files that changed from the base of the PR and between 668b1c8 and 42cecb9.

📒 Files selected for processing (2)
  • .changeset/path-matcher-segment-wildcard.md
  • packages/shared/src/pathMatcher.ts

📝 Walkthrough

Walkthrough

This PR modifies the WithPathPatternWildcard type in @clerk/shared to produce :path* subtree-style wildcard suggestions (e.g., /dashboard/:path*) instead of the previous (.*) regex pattern, with a root-path special case. A changeset documents this type-level autocomplete change.

Changes

Path Wildcard Suggestion Update

Layer / File(s) Summary
Wildcard type and changeset
packages/shared/src/pathMatcher.ts, .changeset/path-matcher-segment-wildcard.md
WithPathPatternWildcard<T> now produces /:path* for root and ${T}/:path* for other paths instead of ${T}(.*); changeset documents the new autocomplete suggestion behavior while noting existing (.*) patterns still work.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

A hop, a skip, a tiny tweak,
No more (.*) did I seek,
Now :path* guides the way,
Through dashboards where routes play,
This bunny's type is clean and neat! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the shared route-type suggestion change to prefer :path* in createRouteMatcher.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Jul 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9057

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9057

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9057

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9057

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9057

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9057

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9057

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9057

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9057

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9057

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9057

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9057

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9057

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9057

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9057

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9057

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9057

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9057

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9057

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9057

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9057

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9057

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9057

commit: 42cecb9

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-07-01T03:24:45.738Z

Summary

Metric Count
Packages analyzed 19
Packages with changes 1
🔴 Breaking changes 1
🟡 Non-breaking changes 0
🟢 Additions 0

Warning
1 breaking change(s) detected - Major version bump required

🤖 This report was reviewed by claude-sonnet-4-6.

🔴 Breaking changes index (1)

Every breaking change, up front. Full diffs are in the package sections below.

Package Subpath Change
@clerk/shared ./pathMatcher WithPathPatternWildcard

@clerk/shared

Current version: 4.23.0
Recommended bump: MAJOR → 5.0.0

Subpath ./pathMatcher

🔴 Breaking Changes (1)

Changed: WithPathPatternWildcard
- type WithPathPatternWildcard<T = string> = `${T & string}(.*)`;
+ type WithPathPatternWildcard<T = string> = T extends '/' ? '/:path*' : `${T & string}/:path*`;

Static analyzer: Breaking change in type alias WithPathPatternWildcard: Type changed: ${T&string}(.*)T extends '/' ? '/:path*':${T&string}/:path*``

🤖 AI review (confirmed) (90%): The resolved string literal pattern changed from ${T}(.*) to a conditional type producing /:path* or ${T}/:path*, so any consumer code that matched, compared, or assigned values against the old template literal pattern (e.g. "/foo(.*)") will no longer satisfy the new type.

Migration: Update any hardcoded path strings or type-level usages from the (.*) suffix pattern (e.g. "/foo(.*)") to the new /:path* suffix pattern (e.g. "/foo/:path*" or "/:path*" for root).


Report generated by Break Check

Last ran on 42cecb9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants