DEV Community


Discussion on: User Authentication with Next.js

jolvera profile image
Juan Olvera Author

Hey flolege, you are very welcome!

When you are using Next.js, the first load of your site will always be from the server, then it will hydrate the site using React. So, we need to check where the request is coming from and get the host from either the server or the client.

Right now we are working on a simplified Authentication example with way less code and easier to understand.

However, that way to get the host should be for development only. And it's meant to be used with Now 2, because every time you deploy you get a new URL. In a regular application, you probably know what's your development and production URLs and you should use those, using environment variables.

I hope I answered your question if not let me know.

flolege profile image

Hey Juan, thanks for your reply. I think I understand. Since the first load is on the server, we do not have access to the window object. So we have to retrieve it another way. many thanks!