Authentication and Route Protection in Nextjs using Higher Order Functions

Опубликовано: 07 Август 2021
на канале: FrostZ
18,101
233

A simple Higher Order Function that handles authentication for any routes in Nextjs. This is a similar approach to HOCs in React. This Higher Order Function can wrap around a GetServerSideProps and protect any route in Nextjs.

Answer on Stack Overflow: https://stackoverflow.com/questions/6...

Note the method that I have used for verifying Cookie is not that perfect, as the cookie is not verified. However here is a link to this same component in a project that I am currently working on which is a bit improved: https://github.com/frostzt/weeee/blob...


Get in touch with me!
GitHub: https://github.com/frostzt