Skip to content

Conversation

@chriscanin
Copy link
Member

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:

@chriscanin chriscanin requested a review from wobsoriano January 22, 2026 21:48
@changeset-bot
Copy link

changeset-bot bot commented Jan 22, 2026

🦋 Changeset detected

Latest commit: 21bb835

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 22, 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 22, 2026 10:25pm

Request Review

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants