From 63d54d76921643474a9ba9c9077bc6aef7abd2b9 Mon Sep 17 00:00:00 2001 From: ChrisCanin Date: Thu, 22 Jan 2026 13:45:52 -0800 Subject: [PATCH 1/4] fix(clerk-js): Handle missing window.location in React Native navigation --- .changeset/evan-bacon-window-location-fix.md | 7 +++++++ packages/clerk-js/src/core/clerk.ts | 21 ++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .changeset/evan-bacon-window-location-fix.md diff --git a/.changeset/evan-bacon-window-location-fix.md b/.changeset/evan-bacon-window-location-fix.md new file mode 100644 index 00000000000..3adbe341355 --- /dev/null +++ b/.changeset/evan-bacon-window-location-fix.md @@ -0,0 +1,7 @@ +--- +"@clerk/clerk-js": patch +--- + +fix(clerk-js): Handle missing window.location in React Native navigation + +Fixed crash in React Native when `window.location` is undefined during navigation (e.g., when Client Trust triggers `needs_second_factor`). In React Native, `window` exists but `window.location` does not, causing navigation to fail when Clerk attempts redirect-based flows. diff --git a/packages/clerk-js/src/core/clerk.ts b/packages/clerk-js/src/core/clerk.ts index 48d108389ce..b6a66601f69 100644 --- a/packages/clerk-js/src/core/clerk.ts +++ b/packages/clerk-js/src/core/clerk.ts @@ -1623,6 +1623,27 @@ export class Clerk implements ClerkInterface { return; } + // In React Native, window exists but window.location does not. + // If we have a custom router, use it directly. Otherwise, return early. + if (typeof window.location === 'undefined') { + const customNavigate = + options?.replace && this.#options.routerReplace ? this.#options.routerReplace : this.#options.routerPush; + + if (customNavigate) { + debugLogger.info(`Clerk is navigating to: ${to}`); + return await customNavigate(to, { windowNavigate }); + } + + // No window.location and no custom router - can't navigate + if (__DEV__) { + console.warn( + 'Clerk: Navigation was attempted but window.location is not available and no custom router (routerPush/routerReplace) was provided. ' + + 'If you are using React Native, please provide routerPush and routerReplace options to ClerkProvider.', + ); + } + return; + } + /** * Trigger all navigation listeners. In order for modal UI components to close. */ From ad45d085a9b40a849a5801b70c166671c91a566c Mon Sep 17 00:00:00 2001 From: ChrisCanin Date: Thu, 22 Jan 2026 13:48:39 -0800 Subject: [PATCH 2/4] fix(clerk-js): Update version to major for handling missing window.location in React Native navigation --- .changeset/evan-bacon-window-location-fix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/evan-bacon-window-location-fix.md b/.changeset/evan-bacon-window-location-fix.md index 3adbe341355..889191ac91a 100644 --- a/.changeset/evan-bacon-window-location-fix.md +++ b/.changeset/evan-bacon-window-location-fix.md @@ -1,5 +1,5 @@ --- -"@clerk/clerk-js": patch +"@clerk/clerk-js": major --- fix(clerk-js): Handle missing window.location in React Native navigation From 8347c8852799affe71ee0cf8f0277f56f91b0c1b Mon Sep 17 00:00:00 2001 From: Christopher Canin Date: Thu, 22 Jan 2026 14:23:56 -0800 Subject: [PATCH 3/4] Fix window.location handling in React Native navigation Update the version of @clerk/clerk-js from major to patch and fix handling of missing window.location in React Native navigation. --- .changeset/evan-bacon-window-location-fix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/evan-bacon-window-location-fix.md b/.changeset/evan-bacon-window-location-fix.md index 889191ac91a..3adbe341355 100644 --- a/.changeset/evan-bacon-window-location-fix.md +++ b/.changeset/evan-bacon-window-location-fix.md @@ -1,5 +1,5 @@ --- -"@clerk/clerk-js": major +"@clerk/clerk-js": patch --- fix(clerk-js): Handle missing window.location in React Native navigation From 21bb83500d5a0c0ccd3412173fee1a780bf293a9 Mon Sep 17 00:00:00 2001 From: Christopher Canin Date: Thu, 22 Jan 2026 14:24:27 -0800 Subject: [PATCH 4/4] Fix missing window.location handling in React Native Fixed crash in React Native when `window.location` is undefined during navigation, improving redirect-based flows. --- .changeset/evan-bacon-window-location-fix.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/.changeset/evan-bacon-window-location-fix.md b/.changeset/evan-bacon-window-location-fix.md index 3adbe341355..68133836b62 100644 --- a/.changeset/evan-bacon-window-location-fix.md +++ b/.changeset/evan-bacon-window-location-fix.md @@ -3,5 +3,3 @@ --- fix(clerk-js): Handle missing window.location in React Native navigation - -Fixed crash in React Native when `window.location` is undefined during navigation (e.g., when Client Trust triggers `needs_second_factor`). In React Native, `window` exists but `window.location` does not, causing navigation to fail when Clerk attempts redirect-based flows.