⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@chriscanin
Copy link
Member

@chriscanin chriscanin commented Jan 23, 2026

Description

The fix that I have added is for the "needs second factor":
When signing in with password on a new/unrecognized device, Clerk's Client Trust feature returns needs_second_factor status. Clerk then tries to navigate to the second factor UI by calling its internal navigate() function.
The problem: navigate() in packages/clerk-js/src/core/clerk.ts does this:
let toURL = new URL(to, window.location.href);
In React Native:

  • window exists (so inBrowser() returns true)
  • window.location is undefined
    Result: Crash with "Cannot read property 'href' of undefined"
    We now check for the window location, and if it cant be found, we will replace the navigation with a router.push / router.replace because in React Native, there's no window.location, the router is the only way to navigate. The fix checks: if window.location is undefined, use the custom router. If no custom router was provided either, warn and bail out gracefully instead of crashing.

MOBILE-392: Evan Bacon - Expo SDK issues

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • Bug Fixes
    • Fixed navigation handling in React Native environments where standard browser location APIs are unavailable, ensuring proper routing through custom router fallbacks and maintaining compatibility across all supported platforms.

✏️ Tip: You can customize this high-level summary in your review settings.

Update the version of @clerk/clerk-js from major to patch and fix handling of missing window.location in React Native navigation.
Fixed crash in React Native when `window.location` is undefined during navigation, improving redirect-based flows.
@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2026

🦋 Changeset detected

Latest commit: 6015884

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

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/expo 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
Copy link

vercel bot commented Jan 23, 2026

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

Project Deployment Review Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jan 23, 2026 6:50pm

Request Review

@chriscanin chriscanin changed the title Chris/mobile 392 evan bacon expo sdk issues new core 3 fix(expo): Chris/mobile 392 evan bacon expo sdk issues new core 3 Jan 23, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 23, 2026

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7665

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7665

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 6015884

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

This change adds React Native compatibility to the Clerk navigation system. A changeset entry documents the patch release, while the core implementation in packages/clerk-js/src/core/clerk.ts adds conditional navigation logic. When the standard window.location object is unavailable—as in React Native environments—the code now checks for a custom router and uses routerReplace or routerPush methods accordingly. If no custom router is available, a development-time warning is emitted. The existing web-based navigation pathway using window.location remains unchanged for standard browser environments.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR directly addresses a crash during React Native navigation with missing window.location, which partially relates to MOBILE-392 React Native incompatibilities but does not resolve all listed objectives. Address remaining issues from MOBILE-392: verification email sending and password sign-in failures for manually added users, or clarify if this PR tackles only navigation crashes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing React Native navigation when window.location is unavailable, with no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title mentions Expo and second factor navigation, which aligns with the main change (handling missing window.location in React Native navigation), but is somewhat vague about the specific fix being a React Native window.location check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@chriscanin chriscanin changed the title fix(expo): Chris/mobile 392 evan bacon expo sdk issues new core 3 fix(expo): needs second factor failing to navigate on expo Jan 23, 2026
@chriscanin chriscanin merged commit 07f66f0 into main Jan 23, 2026
43 of 44 checks passed
@chriscanin chriscanin deleted the chris/mobile-392-evan-bacon-expo-sdk-issues-new-core-3 branch January 23, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants