window undefined on background script when trying to login via firebase

I'm using React + Firebase. I have a hook that handles user details and a background script that handles the auth via chrome.identity.getAuthToken after I approve the consent screen, the background script throws "window is not defined" any ideas? I followed this link - https://www.plasmo.com/blog/posts/firebase-chrome-extension
Firebase Authentication with React in an MV3 Chrome Extension
Diving deep into everything you need to make Firebase Auth work with your MV3 Chrome Extension
9 Replies
ar7casper
ar7casper•2y ago
It uses `sighInWithCredential, and inside it tries to work with local storage on window.
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ar7casper
ar7casper•2y ago
Ye, I'm trying to authenticate using firebase
Arcane
Arcane•2y ago
@ar7casper has reached level 1. GG!
ar7casper
ar7casper•2y ago
In your example, you use a popup, which is nice and all. In my case, I work with a content script. So, I don't have chrome.identity, so I need to use a background script. Then, when I use that, it fails on window.
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Arcane
Arcane•2y ago
@generic has reached level 1. GG!
DevArfat
DevArfat•16mo ago
@ar7casper have you managed to make use of window in it?
ar7casper
ar7casper•16mo ago
The background script is essentially a service worker. It doesn't has any idea about the DOM related stuff. Think of it as a separate server. You need to use sendMessage. That's in general. Regarding Plasmo, haven't tried it yet, will do soon and can report back. Assuming nothing much different there.
Want results from more Discord servers?
Add your server