Next.js Auth | This is the Easiest Way To Build Auth with Cookie Sessions

  Рет қаралды 31,313

Lama Dev

Lama Dev

Күн бұрын

Next.js cookie session auth with iron-session and server actions. Cookie-based authentication and authorization in Next.js 14 app router.
Join the upcoming course wishlist: list.lama.dev
Support
Join the channel: / @lamadev
Buy me a coffee: www.buymeacoffee.com/lamadev
Source Code:
github.com/safak/next-cookie-...
Join Lama Dev groups
X/Twitter: x.com/lamawebdev
Facebook: / lamadev
Instagram: / lamawebdev
Discord: / discord
00:00 Introduction
01:59 Creating Pages in App Router
04:43 Next.js 14 Iron-Session Tutorial
06:40 Cookie Session Auth Server Actions
11:35 How to Get User Session in Next.js?
16:13 Next.js Cookie Session Login with Server Actions
22:19 Next.js Cookie Session Logout with Server Actions
23:09 Next.js Server Actions Show The Form Error with useFormState Hook
25:54 Next.js Protected Routes with Cookie Session
28:09 How to Update the User Session in Next.js?
33:05 Protect the Premium Page in Next.js
35:15 Update the User Session on Each Request in Next.js
39:34 Outro

Пікірлер: 73
@keithgoddard4192
@keithgoddard4192 2 ай бұрын
Wow, this was so useful... your tutorials on NextJS have been a a lifesaver!
@alexandrmeyer
@alexandrmeyer 3 ай бұрын
Thank you VERY MUCH for a great introduction into Iron session. There is no much info about it. If you do more projects on the subject that would be megafantastic!
@san.d_
@san.d_ 3 ай бұрын
Thanks for another awesome tutorial, Lama. I really appreciate it.
@theway_up
@theway_up 3 ай бұрын
Perfect. Thanks for your content!
@morshedulislamriaad6496
@morshedulislamriaad6496 3 ай бұрын
I'm searching for next auth and when i Found lama dev made a video about auth I feel happy.
@ioabhishek
@ioabhishek 3 ай бұрын
Dropped at the right time, Thanks Lamadev
@veerendragumate9132
@veerendragumate9132 3 ай бұрын
Thank you for this, can you go more deep like ,role based auth like user,admin,super admin. And also route protection based on routes.Sociak media auth like google and github.Thank you
@emredurgunlu7570
@emredurgunlu7570 2 ай бұрын
Excellent tutorial. Thank you very much.
@saar2r
@saar2r Ай бұрын
AMAZING! Thank you so much for this clear video 🔥🔥
@dennisngari3557
@dennisngari3557 3 ай бұрын
Thanks lamadev. This one came at the right time..
@zabihullahjan2569
@zabihullahjan2569 3 ай бұрын
Love you lama dev 😘😘😘😘😘😘😘😘 thanks alot for that video 🎉❤
@mastergammer100
@mastergammer100 2 ай бұрын
This worked for me, thank you a lot
@jaay06
@jaay06 2 ай бұрын
Thank you for this tutorial, been wishing to know more about auth And yes, please do more auth tutorials, maybe on on nextauth
@iredoxtech7104
@iredoxtech7104 3 ай бұрын
Thank you for doing this
@nthiwafelix7967
@nthiwafelix7967 3 ай бұрын
Thanks, really helpful.
@StenWasTaken
@StenWasTaken 18 күн бұрын
raelly good tutorial, i really like that you explain whats going on too
@nyctophillia2292
@nyctophillia2292 3 ай бұрын
ITS that easy guys ♥😊 love ur content bro thank you so much ✨📚
@SantoshKumar-sm8pc
@SantoshKumar-sm8pc 3 ай бұрын
I will watch later but i hit like first because your content is always awesome thank you
@dzseroldfabian4574
@dzseroldfabian4574 2 ай бұрын
I would like to see more video about advanced topics related to this
@coder5336
@coder5336 3 ай бұрын
Great
@b166er4
@b166er4 3 ай бұрын
i start 3 years ago with Lama ;), thx for all your content, i was just finishing updating my nextauth with typscript zod, and server actions.... i just make a suggestion, why dont you use middleware to control page access ? as you do in your mern project... i find it more clean and more safe ... happy coding my friend ;)
@user-iw3un8xg9e
@user-iw3un8xg9e 3 ай бұрын
Your videos are amazing as usual, please create a course on next auth with next 14 using providers, protecting routes using middleware, thanks,
@user-vn8pu1gy1y
@user-vn8pu1gy1y 3 ай бұрын
great tutorial, thanks
@imkir4n
@imkir4n 3 ай бұрын
Wow perfect timing.
@Ethan_404
@Ethan_404 3 ай бұрын
thank sir. that is literally helped me....
@xczm225
@xczm225 3 ай бұрын
damn cool video! sure please do more advanced stuff!
@jacobhollakitan3807
@jacobhollakitan3807 3 ай бұрын
Thank you Lama
@umidbekermatov8493
@umidbekermatov8493 3 ай бұрын
Thanks for the tutorial. Now I have a problem with internationalization in Next js 14 with Auth js V5. It would be perfect if the next tutorial is about it
@harunhatiboglu
@harunhatiboglu 3 ай бұрын
Harikasın lamadev 🎉
@krzysztofs3t532
@krzysztofs3t532 3 ай бұрын
Great topic! Thank you very much for this material. BTW - I have special playlist created on YT only for your guides :D
@mounir101
@mounir101 3 ай бұрын
Great one! is this easiest way better than using middleware? thanks a lot and keep up the good work.
@user-ru8ht5xn6s
@user-ru8ht5xn6s 3 ай бұрын
thank you my dear brother...
@rasputinmoore
@rasputinmoore 3 ай бұрын
cool videooo.... since you're asking what kind of videos we'd like to watch i propose you one: Next.js with AWS with Lambda functions
@artrsv
@artrsv 3 ай бұрын
Thank you for the video! Can you tell me how to access user data in client components in this configuration?
@imkir4n
@imkir4n 3 ай бұрын
please continue this and show us the important things such as token rotation .
@ajaysh73
@ajaysh73 3 ай бұрын
you are great!!☺
@Gustavo-bi4hv
@Gustavo-bi4hv 3 ай бұрын
Could you give example using Social auth?
@pjborowiecki2577
@pjborowiecki2577 3 ай бұрын
@LamaDev Thank you for this video. I agree with Gustavo-bi4hv, a continuation to this tutorial with OAuth social sign in or/and magic links would be great
@rashid_rashi009
@rashid_rashi009 3 ай бұрын
Great ❤
@aminda6862
@aminda6862 3 ай бұрын
great thanks
@amirseraj-bt2xs
@amirseraj-bt2xs Ай бұрын
Hi Thankyou for your videos, can you make a video about how can work with NextAuth v5 in Next.js 14 if we have laravel as backend Tnx alot
@shubhjhawar5390
@shubhjhawar5390 3 ай бұрын
⨯ Error: Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead. I get this error when I try to get Session details in my client component, but your's is working in the same way. what am I missing?
@tarekegnkeltaa
@tarekegnkeltaa 3 ай бұрын
Thanks Dear! but we were waiting for the promised VS code extensions and shortcuts video.
@shubhamupadhyay3174
@shubhamupadhyay3174 2 ай бұрын
@renchandara389
@renchandara389 3 ай бұрын
Want to see next js full course release
@sahilsharma1inspirationalTape
@sahilsharma1inspirationalTape 3 ай бұрын
lama Sir can you make a tutorial for making ecommerce marketplace like amazon with minimal scss and nextjs 14 (server actions included, auth, payment gateway and other essential)
@laduniestu
@laduniestu 18 күн бұрын
wow this is great tutorial, but are there any weaknesses in using an authentication system like this?
@dazaiosamuu-yi7sf
@dazaiosamuu-yi7sf 3 ай бұрын
can you please make a project similar to tripadvisor with the mern stack
@SachinSharma590
@SachinSharma590 3 ай бұрын
Bro this is good... But i am stuck how we will use using nodejs and nextjs auth Basically if we are setting cookies from backend server the how nodejs will get it ? With httpOnly ?
@cb73
@cb73 Ай бұрын
How are you not getting this error? "Error: Cookies can only be modified in a Server Action or Route Handler." when adding "const session = await getSession();" to a page?
@liebebilder3529
@liebebilder3529 3 ай бұрын
Could you please give me an idea how to translate dynamic texts in Next.js?
@gurushantupase3306
@gurushantupase3306 Ай бұрын
This was awesome but could you please make for authorization with bearer token and how to protect the routes without any library then it will be the great.
@sinthujanbalachandran6686
@sinthujanbalachandran6686 Ай бұрын
Can't we use middleware to protect the routs rather than writing prtection codes inside each page?
@mdsafikulislam9113
@mdsafikulislam9113 3 ай бұрын
Please make more related tutorials.
@ranawaqas4080
@ranawaqas4080 Ай бұрын
login form is client componet so i can see call in network and password in payload how can we make this more secure ?
@sevenwoleks4658
@sevenwoleks4658 3 ай бұрын
@LamaDev please create a multi step form with react and framer motion
@YuuffyLIVE
@YuuffyLIVE 3 ай бұрын
Why does the logout function only work with form action={logout} and a submit button, but not with onclick handlers like a Button Component that uses onClick={logout} It always resolves in Uncaught in Promise | undefined
@EricLiebrecht
@EricLiebrecht 2 ай бұрын
Because the logout function is only on the server and not the client. With the form action you are sending a request to the server to signal that this function should be executed. Every onclick handler is at the client
@gaming_zen_99
@gaming_zen_99 3 ай бұрын
Bro make a video about both client side and server side validation together in next.js 14 with server actions
@user-kn8jl1cw2x
@user-kn8jl1cw2x 18 күн бұрын
Hi anyone here can help me please im also trying to create a page and when i started to implement iron-session and tried to implement the getSession in my Navbar it started to get an error like react-server-dom-webpack/client module not found very odd error but when i remove the getSession the page works again
@wowgaming2663
@wowgaming2663 2 ай бұрын
Lama i am confused how we know like e commerce website user add to card some product after logout and agin login how we. Fetch the user data how we know this user select this data
@joscript7846
@joscript7846 2 ай бұрын
Each user will have separate IDs. So once u create a user, it's details get stored on Ur database, once u are fetching that user. U get to store his/her details or payloads inside Ur cookies or local storage or straight up with Ur Auth provider, so u check if this user is stored in the cookie is same with the one from Ur database
@vernevens1598
@vernevens1598 2 ай бұрын
Your code from git hub doesn't work.
@cryptoworld1923
@cryptoworld1923 3 ай бұрын
Lama can you provide advance project like Figma clone
@alishakhatri6919
@alishakhatri6919 15 күн бұрын
Can we change password like this even if we dont set in database ?
@shankar66
@shankar66 3 ай бұрын
great video but as i informed you in a previous video comment, the authentication was a little confusing using auuth.dev. please make a separate video step by step and dont use typescript if possible.
@Arvind__7
@Arvind__7 3 ай бұрын
What theme do you use?😕😕😕😕
@usamarazaaq7266
@usamarazaaq7266 3 ай бұрын
Please an e-commerce app with Next Js 14 Mongodb , redux , stripe checkout and deployment on vercel.
@nayemalifahim6701
@nayemalifahim6701 3 ай бұрын
How to host backend and frontend in different domains and use them together.
@SantoshKumar-sm8pc
@SantoshKumar-sm8pc 3 ай бұрын
through api and handle permissions
@gaming_zen_99
@gaming_zen_99 3 ай бұрын
Make a tutorial with Next.js 14, Drizzle and Neon
@andrsh9388
@andrsh9388 3 ай бұрын
go example social media and create db
10 common mistakes with the Next.js App Router
20:37
Vercel
Рет қаралды 182 М.
Китайка и Пчелка 4 серия😂😆
00:19
KITAYKA
Рет қаралды 3,6 МЛН
Just try to use a cool gadget 😍
00:33
123 GO! SHORTS
Рет қаралды 43 МЛН
When someone reclines their seat ✈️
00:21
Adam W
Рет қаралды 26 МЛН
Best VSCode Extensions I'm in Love with
8:36
Lama Dev
Рет қаралды 373 М.
Learn Next.js Parallel Routes In 16 Minutes
16:18
Web Dev Simplified
Рет қаралды 112 М.
CSS Tips And Tricks I Wish I Knew Before
12:12
Lama Dev
Рет қаралды 431 М.
The Story of Next.js
12:13
uidotdev
Рет қаралды 544 М.
Next Auth - JWT & Session Callback & How to Update User Session
31:34
Brett Westwood - Software Engineer
Рет қаралды 41 М.
Auth.js V5 From Scratch
36:41
Sakura Dev
Рет қаралды 17 М.
APPLE совершила РЕВОЛЮЦИЮ!
0:39
ÉЖИ АКСЁНОВ
Рет қаралды 633 М.
ВЫ ЧЕ СДЕЛАЛИ С iOS 18?
22:40
Overtake lab
Рет қаралды 104 М.
Где раздвижные смартфоны ?
0:49
Не шарю!
Рет қаралды 913 М.
Bardak ile Projektör Nasıl Yapılır?
0:19
Safak Novruz
Рет қаралды 6 МЛН