Securely using JWT on the Edge: Authentication in NextJS Middleware!

Josh tried coding

Handling JWT-based authentication inside of NextJS middleware is super fast, and very useful but can be a bit tricky to implement. Let’s look at best practises for implementing JWT auth inside of NextJS middleware, eliminating the need to call a separate API route to handle the JWT authentication. We’ll also pass back the JWT from a tRPC backend route back to the client.

⭐ Our startup:

Thanks for watching, have fun implementing JWT-based authentication inside of your NextJS app!