Next.js Authentication || Register User To MongoDB With Next-Auth V5

  Рет қаралды 3,292

tapaScript by Tapas Adhikary

tapaScript by Tapas Adhikary

Күн бұрын

Enjoy my videos & teaching? Join tapaScript as a member:
/ @tapasadhikary
Learn to persist user data to MongoDB using Next-Auth V5. Continuing from our last video where we used the Credential Provider, now in this step-by-step guide you will learn to interact with MongoDB to persist data through the user registration process.
- Catch up with the previous video on Next-Auth V5 Authentication with Credential Provider: • Next.js Authentication...
Hey, welcome back to another informative video from the "Full Stack With Next.js App Router" series. I hope you enjoy this one the same way you liked the previous videos from the series.
Let's GO 🚀
I take special care to provide you the best quality content. Please SUBSCRIBE to the channel to show your support. Also, could you like/comment on this video so that it reaches others? Thanks! 🫶
Timecodes
0:00 - We Will Learn These
01:45 - Add A Register Link
02:47 - Create Registration Page
04:59 - Add a Login Link
06:36 - API Route Handler for Register
09:48 - Registration Form Submit
14:05 - Test API Route From Register Form
16:29 - The User Schema and Model in MongoDB
21:39 - Establish MongoDB Connection
24:07 - Function To Save User Data To MongoDB
25:45 - Encrypt Password Before Saving
27:16 - Call Function To Create User in MongoDB
29:10 - Test Out The User Registration
31:03 - Change Auth.js For Login Flow
33:41 - Test Out Both Register & Login Flow
34:20 - What's Next?
Source Code on tapaScript GitHub:
- github.com/tapascript/learn-n... (If you like, please support the project with a ⭐)
Join tapaScript Discord
- / discord
🤝 My Links:
- Blog: blog.greenroots.info/
- Follow on X(Twitter): / tapasadhikary
- Connect on LinkedIn: / tapasadhikary
- Follow My Work on GitHub: github.com/atapas
- Follow on Facebook: / tapasadhi
Special Links:
- Are you looking for the best NextJS templates to start your project development? Download and use them for FREE: www.wrappixel.com/templates/c...
- If you are looking for the best content management system, here is something for FREE that you can rely on: app.caisy.io/app/signup/mwiyy...
👋 Like my work? Thank You. You can sponsor me from here:
- Sponsor Me: github.com/sponsors/atapas
- Sponsor my Blog: blog.greenroots.info/sponsor
About Me:
Tapas Adhikary is an Educator at tapaScript, Tech enthusiast, Writer, KZfaqr, and Open Source projects maintainer/contributor. He is a full-stack developer with vast experience in building SaaS solutions. He is the founder of the ReactPlay platform, which is driven by open-source projects and a fast-growing community.
You can find more about him at tapasadhikary.com.
#nextjstutorial
#next
#nextjs14
#nextauth
#authentication
#nextjs
#nextjs13
#nextjsapprouter
#thinkinginnextjs
#nextjstutorial
#next-auth
#authjs
Credit
- The thumbnail uses a login form image that is by "sign in PNG Designed By 祭二 from pngtree.com/freepng/gradient-..."

Пікірлер: 50
@Leesdjo
@Leesdjo 29 күн бұрын
These three parts series about next-auth is seriously helpful. Thank you so much for your time creating it.
@tapasadhikary
@tapasadhikary 29 күн бұрын
Thank you for taking the time and acknowledging it. Appreciate it ❤️
@julianjupiter5890
@julianjupiter5890 18 күн бұрын
Indeed. Because of these I can now finally proceed learning Next.js.
@tapasadhikary
@tapasadhikary 18 күн бұрын
@julianjupiter5890 super
@ashlyvlogs772
@ashlyvlogs772 Ай бұрын
Awesome video and explanation. I am curiously waiting for your next video.
@TAPOSHGHOSH-iu2yx
@TAPOSHGHOSH-iu2yx Ай бұрын
we want to see Role Based User Authorization & Access Control in next js video also . keep doing that type of video.
@tawsifhaque9360
@tawsifhaque9360 Ай бұрын
Excellent video as always and once again. Really rrally grateful to you and your content. Extremely appreciate the efforts you put in to make the concepts as easy as they can be. For a while now i was scouring the internet for easy to understand credentials login using next auth in an easy way. Only your video i came across that made me understand the concept extremely well. Such quality content deaerves more recognition. Thank you once again for making the concepts stupidly simple to understand. Im definitely going to save this video as one of my favorites in KZfaq and will refer back to it from time to time. Thank you much sir
@tapasadhikary
@tapasadhikary Ай бұрын
You are most welcome ❤️ Once you all share my content with others who may need it, will be a great help, too. Thanks a lot.
@ashlyvlogs772
@ashlyvlogs772 Ай бұрын
Can you please make a video on keeping the session and using the session authentication in client pages after logging in?
@mehmethanifierenler3612
@mehmethanifierenler3612 Ай бұрын
very very thanks, i waiting posgrsql + drizzle
@__Gojo___
@__Gojo___ Ай бұрын
Waiting for Next part with access and refresh token handle ❤️
@tapasadhikary
@tapasadhikary Ай бұрын
Everyone is asking for this one 😀 I've planned it for June.
@steffenjusmann6276
@steffenjusmann6276 29 күн бұрын
please continue this series!! It is very helpful :)
@tapasadhikary
@tapasadhikary 29 күн бұрын
Absolutely! Next one is coming today 😄
@steffenjusmann6276
@steffenjusmann6276 29 күн бұрын
@@tapasadhikary Looking forward to that :)
@tapasadhikary
@tapasadhikary 29 күн бұрын
@@steffenjusmann6276 sorry I meant coming tomorrow, Thursday IST evening
@steffenjusmann6276
@steffenjusmann6276 10 күн бұрын
@@tapasadhikary I have a question regarding the auth session. How can I get the user _id from the MongoDB into my session? Currently, the session.user just has name and email. However, I would need the id as well. How can I add this to the session?
@sohaibabdullah9073
@sohaibabdullah9073 Ай бұрын
Great sir g
@tapasadhikary
@tapasadhikary Ай бұрын
Thanks, Sir G 🤟
@syedbilalchand1766
@syedbilalchand1766 Ай бұрын
can you please make a video on the refresh token and access token in authv5
@tapasadhikary
@tapasadhikary Ай бұрын
Of course I can 😀 It's planned for June.
@nichas143
@nichas143 27 күн бұрын
Dada dil jeet liya aapne.. you have done it the best, have been through so many videos, udemy and so on.. You can be a Udemy star too. Thank you so much and keep it coming. My request is to suggest how zod can be useful along with typescript.
@tapasadhikary
@tapasadhikary 27 күн бұрын
Vai hardly people value free content, even there are so much effort and authenticity in it… I'm glad, my content and teaching started seeing the lights 😀🔥
@nichas143
@nichas143 27 күн бұрын
@@tapasadhikary Its not free its invaluable. I have gone through so much of content, I loved the way you teach so simply. Thankyou sir. Will keep waiting for more content from you.
@ZulfikarPremium
@ZulfikarPremium Ай бұрын
include session or just add data to table user ?
@abdullahhasan4188
@abdullahhasan4188 Ай бұрын
awesome Dada , how do i use next auth v5 session in middleware ?? please make a video on it. Thank you so much for your great content.
@tapasadhikary
@tapasadhikary Ай бұрын
You are welcome vai… it will come in a future video, planned already. One request would be please share about this next.js series with people so that there is awareness. Thanks ❤️🔥
@tusharphb6596
@tusharphb6596 Ай бұрын
Thanks Dada for this detailed video of authjs v5 ❤ I have fewer questions like authjs v5 is ready to use for production? As it is still in beta. There are other alternatives like Auth0 and Lucia Auth, should we go for them for production or use authJs beta in production?
@tapasadhikary
@tapasadhikary Ай бұрын
Welcome. Yes, Next-Auth V5 is not stable yet. That's one reason I am making these content with my discoveries with it. It still has issues, but we hope to be stable soon. An alternative open-source(if possible free) & stable solution is surely worth looking into in the mean time.
@alexdin1565
@alexdin1565 6 күн бұрын
please can you make a video about login using facebook?
@tapasadhikary
@tapasadhikary 3 күн бұрын
Won't it be mostly similar to the two I showed here? Are you facing any issues with FB?
@imkir4n
@imkir4n Ай бұрын
Hello brother, please implement the refresh token logic as well. I'm struggling to do it in NextAuth.
@tapasadhikary
@tapasadhikary Ай бұрын
Bro, keep eye on this series. Its coming. I'll be implementing it on top of same code incrementally. Cheers!
@imkir4n
@imkir4n Ай бұрын
@@tapasadhikary Sure, Cheers!
@Pushkarcdn
@Pushkarcdn 17 күн бұрын
#504_error Sir, I have done everything same as done in the video... Then, 1. Changed the MONGO connection string to my mongo db atlas 2. Published the app on vercel 3. Set environment variables on vercel (including connection string) 4. Allowed all ip to connect to my mongodb atlas The signup process is working fine but the Login is not working. It says 504 gateway timeout. The same project when run on local it is working, only on vercel, it's showing 504 (only while logging in) Solutions tried: 1. Integrated vercel to mongodb atlas (as per stackoverflow community answers). 2. Allowed all ips to access my mongo db atlas What should i do to fix it ?
@tapasadhikary
@tapasadhikary 17 күн бұрын
Hey, thanks for trying out the deployment on Vercel and Atlas.... I have not tried it but my deployment is on Cloudflare and Atlas for a company project... It is working. The steps you mentioned is almost same. Make sure the IPs are correct. I would recommend you discuss this on our Discord as it is easier to see the log and screenshot to help out.. also other folks on discord may pitch in or learn from it. All the best.
@ericsiddiq7634
@ericsiddiq7634 Ай бұрын
❤❤❤❤❤
@tapasadhikary
@tapasadhikary Ай бұрын
❤❤❤
@monir63
@monir63 Ай бұрын
How to protect api endpoint with middlwer and make private routes with middlwer make videos
@tapasadhikary
@tapasadhikary Ай бұрын
That's the next video coming this week 😊
@monir63
@monir63 Ай бұрын
@@tapasadhikary thanks
@Anurag_Badwahe
@Anurag_Badwahe Ай бұрын
Sir auth provider local me work kar rahe par production me nahi.. How can i solve this issur
@tapasadhikary
@tapasadhikary Ай бұрын
Issue kiya hai vai?
@Anurag_Badwahe
@Anurag_Badwahe Ай бұрын
@@tapasadhikary domain_name/api/auth/error?error=Illegal%20arguments%3A%20undefined%2C%20number
@Anurag_Badwahe
@Anurag_Badwahe Ай бұрын
screen pe ek div aata hai uspe Error phir niche domain name likha aata hai
@SonuSingh-sm7jy
@SonuSingh-sm7jy 10 күн бұрын
post method not working of your github repo when i register why is that?
@tapasadhikary
@tapasadhikary 10 күн бұрын
It should sir, I push working code. Make sure the env is correct with mongo string and your database name. All the best.
@SonuSingh-sm7jy
@SonuSingh-sm7jy 10 күн бұрын
@@tapasadhikary did not work i tried 20 times , i clone your git repo then it not still register post request working then i trigger register button ,then it will triger login api why is that happens sir?
@MohammadNazim-nm8pf
@MohammadNazim-nm8pf 9 күн бұрын
Can you please make a video on keeping the session and using the session authentication in client pages after logging in?
@tapasadhikary
@tapasadhikary 9 күн бұрын
Yes that video will come around 7th July. Already planned. Thanks.
Next.js Middleware Crash Course || App Router Protected Routes
1:01:02
tapaScript by Tapas Adhikary
Рет қаралды 2,8 М.
Connect Google Provider to Database - Next Auth
40:00
Brett Westwood - Software Engineer
Рет қаралды 10 М.
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 3,7 МЛН
When You Get Ran Over By A Car...
00:15
Jojo Sim
Рет қаралды 12 МЛН
Вечный ДВИГАТЕЛЬ!⚙️ #shorts
00:27
Гараж 54
Рет қаралды 13 МЛН
Next.js App Router Multiple Root Layouts: Explained With Examples
14:33
tapaScript by Tapas Adhikary
Рет қаралды 6 М.
Next.js Authentication With Next-Auth V5 || Google & GitHub
37:29
tapaScript by Tapas Adhikary
Рет қаралды 5 М.
Next js 15 is Here… New Changes Again?!
8:13
JavaScript Mastery
Рет қаралды 125 М.
Next Auth v5 Complete Guide in Next.js 15 with Prisma and MongoDB
1:22:52
Programming with Umair
Рет қаралды 1,9 М.
Full Stack Authentication With Next.JS | Next Auth | Nest.JS
1:33:47
Next.js App Router Parallel Routes: Explained With Project
33:52
tapaScript by Tapas Adhikary
Рет қаралды 2,1 М.
Design a Simple Authentication System | System Design Interview Prep
17:22