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

preview_player
Показать описание
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.

Thanks for watching, have fun implementing JWT-based authentication inside of your NextJS app!
Рекомендации по теме
Комментарии
Автор

Hi, I liked the protected routing using middelware. But what if, for example, we are using an external backend, you would still recommend using this approach, minus the token verification (because that is already happening on the backend)?

hepsko
Автор

Useful knowledge.. Hope, next will be NextAuth with the JWT access token Register, Login and User Access Role..!

saharilarshad
Автор

nextjs 인증강의를 검색하던중 찾았습니다. 감사합니다.
nextjs 를 처음배우는데 영어를 몰라서 자동번역으로 보면서 겨우겨우 따라하고 있습니다.

bongjames
Автор

Which snippet extension do you use? I like the way you can just write state and the useState is autocompleted.

mohaniya
Автор

if we have to show user data in /dashboard page, how can we do that

we can do so by getServerSideProps

but what if we have to show userData in Navbar(email), /profile page


for client-side we can use useEffect
BUT
what if we have to show data in Navbar, dashboar, profile page on the very first page load

easy-peasy-tutorials
Автор

Hey Josh I notice that when I redirect the upload still shows the path of the previous page. Any way to fix that

ambrosebeavers
Автор

Hello is there any handling refresh token using axios related to this video?

Sasuke-pxkm
Автор

Bro please complete the booking system playlist, the idea looks awesome

developer_hadi
Автор

If user is logged in and if they still wanna access /login then how to redirect them to " /" page

webber
Автор

well explained. is there a github link ?

nuuklu
Автор

Hi, where can I find this example on your github?

kirielbe
Автор

Hey Josh thanks for this, I'm using this for my new project but I'm having an issue how do I protect dynamic routes? for example I want to protect this route "/customer/[id]"

ashankarunaratne
Автор

how to can i implement logout? I just need to delete the cookie on client side?

christianstamati
Автор

혹시 trpc 를 사용하지 않고 middleware 를 만든 영상도 있습니까?

bongjames
Автор

Thank You. this is very petrified doing authentication in middleware.
but something strange happened to my nextjs app in production mode. I logged out and changed the maxAge in the serial cookie to -1. cookies deleted successfully but i can still access admin page. sometimes the data displayed is data from other users at different levels who have logged in on their respective devices. Please help and sorry for my english

rizkifahruroji
Автор

hi Josh, your video helpful with me, when i do with my project, it run perfectly in local, but when i deployed on vercel, the middleware not working, it mean the JWT - verifyToken not working, token isn't authenticated. Can you help me.

LeagueofLegendMoment
Автор

awesome video !, can u implement refreshToken on the next video ... cant wait for another video from u

ghalitsar
Автор

What is the "on the edge "exactly..

justiceessiel
Автор

Where did you get that wallpaper? It's really really cool!

chamir
Автор

what does Edge mean, I often hear it, but I can’t understand it, because English is not my main language, is it like a browser from Microsoft?

tymurkr