Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
5 replies
george

Protected Routes

How do you create your Protected Routes?

I've seen a lot of suggestions to use middleware, but for that, I need a JWT, and I use server cookies (which is probably safer - or should I rush the JWT?)

However, I am not talking about the fact that the user is redirected from the protected page if he/she is not logged in. I mean, I need more advanced filtering.

For example, if the user is over 18, he can enter a given website, if not, it will redirect him to another. Or whether the user has a confirmed email address, that sort of thing.

So far I've created a wrapper <Auth> (picture) but I don't know if it's a good approach
image.png
Was this page helpful?