Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReferenceError: window is not defined in React Native project after adding Supabase call

I'm using a React Native project with Expo v49, and I added a Supabase call to read some data from the database, and it works on ios/android,

But when I open the web version, I get "ReferenceError: window is not defined", and it shows the error is somewhere in the expo-router package

Any help would be appreciated

Tldr: I added the supabase-js call in a useEffect hook of my component (to fetch the backend data), and it works on mobile, but not on React Native Web.

like image 716
shadowcrux Avatar asked Jul 19 '26 15:07

shadowcrux


1 Answers

To prevent this behavior, set output in your app.json from "output": "static", to "output": "single",. Had the same problem using react-native, expo, and supabase and this change fixed it for me.

Source: helpful reddit post

like image 71
stayingcozy Avatar answered Jul 21 '26 05:07

stayingcozy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!