auth0 / lock-passwordless

Auth0 Lock Passwordless [DEPRECATED]
MIT License
90 stars 29 forks source link

server side rendering #121

Open luisrudge opened 8 years ago

luisrudge commented 8 years ago

I'm trying to use this lib with an universal app, but it's throwing an exception here because document is undefined when it's a server side render. Can we add a check to see if document exists or perhaps only run this code inside the constructor?

luisrudge commented 8 years ago

Actually, this happens in other places as well:

kievechua commented 7 years ago

Needed this as well, basically the document just used for injecting style. Any timeframe we can expect? Or the team not plan to work on this at all?

kievechua commented 7 years ago

If your using next.js, check out this blog building-universal-apps-with-nextjs Replace the cdn with this instead <script src="http://cdn.auth0.com/js/lock-passwordless-2.2.3.min.js"></script>

jensdotbruggeman commented 7 years ago

I receive the same error, basically document is not defined using server side rendering.

For example , failing on document : https://github.com/auth0/lock-passwordless/blob/master/src/atom/index.js#L3

how can I solve this? I use an Angular2 app combined with asp.NET Javascript services.

luisrudge commented 7 years ago

To solve this, you have to make sure to require this lib only in the client. In angular, I think you can require it on dom load.