Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to avoid the boilerplate for auth check? #2

Open
9bits opened this issue May 14, 2020 · 0 comments
Open

How to avoid the boilerplate for auth check? #2

9bits opened this issue May 14, 2020 · 0 comments

Comments

@9bits
Copy link

9bits commented May 14, 2020

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('/');
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant