Authentication
Yes, this can be a debatable topic and depend on your needs. This template uses next-auth library. Which is straight forward and simple to use.
This library is capable of lot of things. Its better to head over next-auth and read about it.
There is middleware withAuth.ts
which we can wrap with any controllers and it will make sure only authenticated users reach.
Example,
withAuth(createPost)
Client side we can use AuthRequired
component.
You can just wrap you component with AuthRequired
and it will make sure auth is required and show login link there if not.
Example,
<AuthRequired> <PostForm /></AuthRequired>