Window.location.href is undefined on react-native
See original GitHub issueBug report
Describe the bug
When creating a new project using Expo-cli react-native and setting it up with a simple Supabase database, it crashes when building on Android. It runs fine on web version. The underlying issue is I believe with the goTrue.js library which takes window.location.href as argument but on mobile devices window.location is undefined see screenshot.
To Reproduce
Setup a new Expo project and install Supabase using the following client setup
import AsyncStorage from '@react-native-async-storage/async-storage'
import {REACT_APP_SUPABASE_URL, REACT_APP_SUPABASE_ANON_KEY} from "@env";
const supabaseUrl = REACT_APP_SUPABASE_URL
const supabaseAnonKey = REACT_APP_SUPABASE_ANON_KEY
console.log(supabaseUrl, supabaseAnonKey)
export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
localStorage: AsyncStorage
})
Run it using expo start
and connect expo to an android device
Expected behavior
The project builds succesfully
Screenshots
System information
- OS: Windows + WSL
- Version of supabase-js: 1.25.2
- Expo version: 42.0.1
- Version of Node.js: v14.17.4
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Why is window.location undefined in React Native?
href . While window is defined as a global in React Native, it's missing location . This looks like it's intentional, rather than...
Read more >window.location Cheatsheet | SamanthaMing.com
The window.location object can be used to get information on the current page address (URL). You can also use its method to do...
Read more >JavaScript Window Location
Window Location Href. The window.location.href property returns the URL of the current page. · Window Location Hostname. The window.location. · Window Location ...
Read more >Linking
Linking gives you a general interface to interact with both incoming and outgoing app links.
Read more >Is it okay to use window.location.href in react? : r/reactjs
I have a logout function that is a pure JS file with no react component. I wish to go back to the login...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
same this bug persists in new v2 when using signInWithOAuth in expo RN
I’m also having this problem in RN using the signInWithOAuth function