hoc-private-route-next-js Assalamo alaikum....
Here I gonna show you how to use HOC(Higher Order Component) to make a private route in Next JS.
But you can use this also in React.
What I have done?
-
I used a js file where I have written some functions which will help us to get, set, delete, delete all the cookies in browser cookies.
-
I made a HOC function to authenticate any component which will be in the private route.
-
A home page with a basic design, we will see. From there We can go to the dashboard if the user signed in.
-
A navbar will be used to navigate the Dashboard page, homepage, login page, or logout.
Here is the repository link: https://github.com/MusiurAlamOpu/hoc-private-route-next-js
Demo Site link: https://hoc-private-route-next-js.vercel.app/
If you want to know further or facing any problem regarding implementation...let me know via my email musiuralamo@gmail.com
Zajakallahu khayer.