nextjs-auth0-starter
nextjs-auth0-starter copied to clipboard
How to avoid the boilerplate for auth check?
Thanks for the tutorial!
I'm currently struggling to create a template that can be shared by all pages so I don't have to write the auth boilerplate everytime. Is there a way around it?
https://github.com/CaptainChemist/nextjs-auth0-starter/blob/master/pages/profile.tsx#L15-L26
Having to write this all the time will be extremely tedious
const { user, loading } = useFetchUser();
if (loading) {
return (
<MainLayout>
<p>Loading...</p>
</MainLayout>
);
}
if (!user && !loading) {
Router.replace('/');
}