From b5f6aedb11fad55cb2ff63d009b325eca46306de Mon Sep 17 00:00:00 2001 From: Jacek Date: Mon, 6 Jul 2026 15:17:55 -0500 Subject: [PATCH] chore(shared): Deprecate createPathMatcher --- .changeset/shared-deprecate-path-matcher.md | 5 +++++ packages/shared/src/pathMatcher.ts | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .changeset/shared-deprecate-path-matcher.md diff --git a/.changeset/shared-deprecate-path-matcher.md b/.changeset/shared-deprecate-path-matcher.md new file mode 100644 index 00000000000..dd5d7eaebba --- /dev/null +++ b/.changeset/shared-deprecate-path-matcher.md @@ -0,0 +1,5 @@ +--- +'@clerk/shared': patch +--- + +Deprecate `createPathMatcher()` and its pattern types (`PathMatcherParam`, `PathPattern`, `WithPathSegmentWildcard`). Pattern-based path matching is being phased out along with the framework-level `createRouteMatcher()` helpers and will be removed in the next major version. Use your framework's native routing primitives to decide which paths to protect instead. diff --git a/packages/shared/src/pathMatcher.ts b/packages/shared/src/pathMatcher.ts index dc9c901f4a1..e237b06c305 100644 --- a/packages/shared/src/pathMatcher.ts +++ b/packages/shared/src/pathMatcher.ts @@ -16,11 +16,19 @@ type StripTrailingSlash = T extends '/' /** * Suggests the `:path*` subtree form (e.g. `/dashboard/:path*`), which matches on * path-segment boundaries. `/` is special-cased to `/:path*` to avoid a malformed `//:path*`. + * + * @deprecated Will be removed in the next major version together with {@link createPathMatcher}. */ export type WithPathSegmentWildcard = T extends '/' ? '/:path*' : `${StripTrailingSlash}/:path*`; +/** + * @deprecated Will be removed in the next major version together with {@link createPathMatcher}. + */ export type PathPattern = Autocomplete; +/** + * @deprecated Will be removed in the next major version together with {@link createPathMatcher}. + */ export type PathMatcherParam = Array | RegExp | PathPattern; export class MalformedURLError extends Error { @@ -70,6 +78,10 @@ export const normalizePath = (pathname: string): string => { * * @param patterns - A string, RegExp, or array of patterns to match against * @returns A function that takes a pathname and returns true if it matches any of the patterns + * + * @deprecated This function will be removed in the next major version. Pattern-based path matching + * can diverge from how frameworks route requests; use your framework's native routing primitives + * to decide which paths to protect instead. */ export const createPathMatcher = (patterns: PathMatcherParam) => { const routePatterns = [patterns || ''].flat().filter(Boolean);