samuelgozi / firebase-auth-lite

A lightweight firebase auth alternative for the browser
MIT License
119 stars 19 forks source link

Feature Request: Support SSR #50

Open arunmenon1975 opened 4 years ago

arunmenon1975 commented 4 years ago

I am integrating authlite into a new SSR project and found a few issues. I am currently working around them by directly editing the main.js file with the following changes:

if (typeof window === 'undefined') {
    global.window = {}
}

and

if (typeof window !== 'undefined') {
    ['set', 'get', 'remove'].forEach(m => (storageApi[m] = async (k, v) => localStorage[m + 'Item'](k, v)));
}

and

if (typeof window !== 'undefined') {
    this.storage.get(this.sKey('User')).then(user => {
....
}

So far, though i have just started, the above changes stops the immediate issues and am able to compile successfully. I think supporting SSR would help make the library much more versatile. It already does support react-native as well.

issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.85. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

samuelgozi commented 3 years ago

Thanks for letting me know, Ill take a look and see what I can do about it. I want to avoid having x is undefined issues. And sorry for the big delay.