How do you go about setting up protected routes? if we do conditional rendering using the onauthstatechanged function, that makes that whole page a client page right?
That is a great question, I guess this is something that people do a bit differently, but I don't think it's wrong to have the check in a client page since in the end what is the website if not a user interface reflecting our data we have in the backend. It's quite common to always assume the user is signed in if we have a firebase user when we render and once you do a fetch for data from firebase and that user is not valid, then you clear all the local data and show them out to the sign in page for example. You can for example do it something like this Medium post here: innocentanyaele.medium.com/protect-pages-from-unauthorized-access-nextjs-firebase-45fd9ee732b4 or just wrap a layout page in the root of what should be accessible with one of the SignedIn components from the video 🙂 sorry for the long rant, hope this helps!
@@chunkydotdev Thank you so much for the prompt reply, I'll surely look into the medium post. You're doing a great job btw, with the videos really helps out people like me who are exploring nextjs for the first time!
How do you go about setting up protected routes? if we do conditional rendering using the onauthstatechanged function, that makes that whole page a client page right?
That is a great question, I guess this is something that people do a bit differently, but I don't think it's wrong to have the check in a client page since in the end what is the website if not a user interface reflecting our data we have in the backend. It's quite common to always assume the user is signed in if we have a firebase user when we render and once you do a fetch for data from firebase and that user is not valid, then you clear all the local data and show them out to the sign in page for example. You can for example do it something like this Medium post here: innocentanyaele.medium.com/protect-pages-from-unauthorized-access-nextjs-firebase-45fd9ee732b4 or just wrap a layout page in the root of what should be accessible with one of the SignedIn components from the video 🙂 sorry for the long rant, hope this helps!
@@chunkydotdev Thank you so much for the prompt reply, I'll surely look into the medium post. You're doing a great job btw, with the videos really helps out people like me who are exploring nextjs for the first time!