question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Window.location.href is undefined on react-native

See original GitHub issue

Bug 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

afbeelding

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:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
nrowleycommented, Oct 24, 2022

same this bug persists in new v2 when using signInWithOAuth in expo RN

2reactions
gustavodiasobtradercommented, Nov 26, 2022

I’m also having this problem in RN using the signInWithOAuth function

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found