File tree Expand file tree Collapse file tree
packages/clerk-js/src/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @clerk/clerk-js ' : patch
3+ ---
4+
5+ fix(clerk-js): Handle missing window.location in React Native navigation
Original file line number Diff line number Diff line change @@ -1666,6 +1666,27 @@ export class Clerk implements ClerkInterface {
16661666 return ;
16671667 }
16681668
1669+ // In React Native, window exists but window.location does not.
1670+ // If we have a custom router, use it directly. Otherwise, return early.
1671+ if ( typeof window . location === 'undefined' ) {
1672+ const customNavigate =
1673+ options ?. replace && this . #options. routerReplace ? this . #options. routerReplace : this . #options. routerPush ;
1674+
1675+ if ( customNavigate ) {
1676+ debugLogger . info ( `Clerk is navigating to: ${ to } ` ) ;
1677+ return await customNavigate ( to , { windowNavigate } ) ;
1678+ }
1679+
1680+ // No window.location and no custom router - can't navigate
1681+ if ( __DEV__ ) {
1682+ console . warn (
1683+ 'Clerk: Navigation was attempted but window.location is not available and no custom router (routerPush/routerReplace) was provided. ' +
1684+ 'If you are using React Native, please provide routerPush and routerReplace options to ClerkProvider.' ,
1685+ ) ;
1686+ }
1687+ return ;
1688+ }
1689+
16691690 /**
16701691 * Trigger all navigation listeners. In order for modal UI components to close.
16711692 */
You can’t perform that action at this time.
0 commit comments