Next.js 13 Authentication: Custom Email/Password with NextAuth.js & MongoDB

  Рет қаралды 80,224

GTCoding

GTCoding

Күн бұрын

Check out my courses: gtcoding.net/courses/
In this comprehensive tutorial you will learn how to add authentication to your Next.js 13 app with Email/Password using Next Auth. We will use MongoDB to store the details of the user. We will be using Tailwind CSS for designing the UI.
Source code: github.com/Godsont/auth-with-...
Timestamps:
-----------------------
00:00 - Demo
02:59 - Designing UI Using Tailwind CSS
16:41 - Creating the API
27:07 - MongoDB
42:48 - Authentication using Next Auth

Пікірлер: 164
@MisbahuA
@MisbahuA 3 ай бұрын
This is one of the best tutorials seen on Nextjs, mongoose and nextauth. Thank you good Sir, really appreciate your effort. Keep it up
@chiderathankgodobed4496
@chiderathankgodobed4496 6 ай бұрын
fantastic piece on nextauth using app router, I have been having issues integrating next-auth, but your video has made lide easy , Thanks GT coding
@alokjoshi334
@alokjoshi334 10 ай бұрын
Thanks a lot for the NextJS 13 videos and end to end projects with database functionality, very much appreciated! very simple and straightforward explanations. Keep up the good work.
@GTCoding
@GTCoding 10 ай бұрын
Thank you :)
@BadrudeenAbdul-hameed
@BadrudeenAbdul-hameed 6 ай бұрын
This is reeeeally awesome and on point for my use case. I have been battling with authentication for 2 days now, and your video just saved a life. I can't thank you enough.
@vernevens1598
@vernevens1598 Ай бұрын
Only 2 days?
@Salah-YT
@Salah-YT 3 ай бұрын
Thank you immensely! Your video provided the best tutorial I've ever come across. Your effort is highly appreciated. Wishing you a life filled with greatness. Thanks again!
@Dekorozi
@Dekorozi 10 ай бұрын
Thank you for great Next JS videos. I watched your last NextJs videos. We learnt making contact page, crud and auth. Now I am waiting for a full project video like a blog website with mongodb :)
@HimanshuKumar-rn1cn
@HimanshuKumar-rn1cn 8 ай бұрын
this was the perfect video for my use case, I wanted to have a custom login and register form without using any google or github provider. Other videos have complex providers and if they implement only credentials, they didnt use database. This video was very helpful thanks
@chiderathankgodobed4496
@chiderathankgodobed4496 7 ай бұрын
This is has to be the best tutorial i have seen in nextjs auth, thanks so much @GtCoding
@JanBuilds
@JanBuilds 9 ай бұрын
Thanks for the tutorial using javascript, not typescript! I have been looking for this for quite a while! :) 🙏🤓
@parspy694
@parspy694 7 ай бұрын
this is one of the best tutorial i've ever seen kudos to you sir
@tomasburian6550
@tomasburian6550 5 ай бұрын
This works great with JS, but in the professional world we use TypeScript so we could use the tutorial that also includes types, Next Auth is quite difficult to type so maybe make a video in the future to include that.
@terry_swd
@terry_swd 3 ай бұрын
Awesome tutorial! I would also add a little success message when user registration is successful in addition to clearing the form. Also it would be nice to reset any previous error state after a successful registration.
@toltec1983
@toltec1983 8 ай бұрын
best tutorial on the subject on yt.
@amirhosseinqafari9747
@amirhosseinqafari9747 5 ай бұрын
Great, thanks for this solid tutorial.
@kbchannel83
@kbchannel83 3 ай бұрын
Thank You for this video, it's really helpful.
@codemelon2698
@codemelon2698 10 ай бұрын
this video is awesome keep up the amazing work
@GeorgeDonnelly
@GeorgeDonnelly 7 ай бұрын
This was outstanding, thank you!
@leonardohurovich3381
@leonardohurovich3381 9 ай бұрын
Great video! Love it! Thank you sir
@veggtips.shorts
@veggtips.shorts 8 ай бұрын
Nice content! So helpful, i really appreciate...Thanksss!
@raduscortescu6512
@raduscortescu6512 7 ай бұрын
Thanks, man! Simple great tutorial!
@adelinaakylbekova308
@adelinaakylbekova308 28 күн бұрын
Thank you for this tutorial
@sravankumar8763
@sravankumar8763 Ай бұрын
Very good video, want to spend time and have my custom auth . you saved me a lot of lot of time
@joakuvideo
@joakuvideo 7 ай бұрын
Impressive! I changed it a little bit for using prisma. :) thanks!
@leomeynard7671
@leomeynard7671 6 ай бұрын
Thank you, you explain it well.
@lembazaa7330
@lembazaa7330 7 ай бұрын
thanks a lot you are the besty one that explane this next auth thanks broo keep going 😃😁
@maskman4821
@maskman4821 6 ай бұрын
Great tutorial ❤
@Nanashi-rq7lk
@Nanashi-rq7lk 10 ай бұрын
Thanks tutorial. your viedo is good.
@codigo6273
@codigo6273 8 ай бұрын
Thanks a lot for this video📌
@patlagoon
@patlagoon 5 ай бұрын
Thanks for this tutorial, it's really clear. I was struggling to understand authentication and this helped me tremendously. Could you do a follow up on this topic with "email validation" after registering and "forgot your email?" functionalities ?
@manzurajshahi
@manzurajshahi 10 ай бұрын
I really needed this simple login using NextApp. Thank you for this beautiful tutorial. I request to you. Please add "Forget password" feature for this tutorial.😊
@hakanaki
@hakanaki 7 ай бұрын
Thank you for this tutorial. Every other KZfaqr is just doing login with Google SMH
@nguyenlehuuduy6272
@nguyenlehuuduy6272 3 ай бұрын
Thank you immensely!
@PauloRdeOFerraz
@PauloRdeOFerraz 6 ай бұрын
Impressed with the quality, congratulations! A question regarding next-auth. Would it be possible to use the same database with registered users to create a login for another React Native application, for instance?
@sarbeswarsahoo8579
@sarbeswarsahoo8579 10 ай бұрын
Thanks a lot for the video
@taukiralam414
@taukiralam414 8 ай бұрын
Man you are the best ..
@piodgamer4084
@piodgamer4084 23 күн бұрын
Thanks bro It's very good peace and love ^.^
@byronloarte
@byronloarte 10 ай бұрын
Great video and more content about Next.JS please my dear friend 🙏
@GTCoding
@GTCoding 10 ай бұрын
Sure 👍
@wayvroom
@wayvroom 7 ай бұрын
Awesome tutorial my brother keep it up ❤
@tempuser9560
@tempuser9560 9 ай бұрын
Awesome explanation about Next JS 13 Authentication. Thanks a lot. Can you please make one video with mysql server instead of mongoose. and with image upload functionality. Thanks a lot in advance!
@zee_designs
@zee_designs 9 ай бұрын
Straightforward approach 🦾
@MarcosFelipe-up9lc
@MarcosFelipe-up9lc 5 ай бұрын
Thanks bro!!
@surindersingh7799
@surindersingh7799 6 ай бұрын
great video :)
@ManiSingh-gr7zi
@ManiSingh-gr7zi 3 ай бұрын
Thank you.
@michellaurent1361
@michellaurent1361 7 ай бұрын
thanks you, perfect
@mijeongwon2355
@mijeongwon2355 8 ай бұрын
Thanks a lot!
@Ruben-sc7dj
@Ruben-sc7dj 8 ай бұрын
Thank you!:)
@mrrafay2530
@mrrafay2530 6 ай бұрын
Good tutorial kindly also add role base authentication in this project
@afzaalahmedtai8211
@afzaalahmedtai8211 8 ай бұрын
Thanks for amazing video but I didn't understand that why did you make another API to check user exist or not. Can we check while register user in register API?
@user-kx8gv2yk4v
@user-kx8gv2yk4v 9 ай бұрын
Could you make a tutorial about how to use the jwt and cookie to store the user's login condition with nextjs and next-auth? Thank you very much
9 ай бұрын
Thank you soo much
@ezequieloliveira222
@ezequieloliveira222 3 ай бұрын
Muito bom bem explicado e simples, so achei esse e JS e não em Typscript
@Hasoon-ry8pu
@Hasoon-ry8pu 10 ай бұрын
Thanks for this video. Will you make a complete blog that brings together all the concepts?
@GTCoding
@GTCoding 10 ай бұрын
Sure.
@piotrrodzen772
@piotrrodzen772 9 ай бұрын
great tutorial. Perhaps you could also add password system with JWT as I feel its much more secure in general
@judevector
@judevector 8 ай бұрын
Jwt is not for password,bcrypt is . Jwt is for cookies , sessions and I think next-auth comes automatically with it , you can see he use jwt in that credentials there ,am thinking maybe that's how it's been used in NextJS unlike Nodejs
@testing-jr8tz
@testing-jr8tz 4 ай бұрын
thanks man
@darshanathamara8546
@darshanathamara8546 9 ай бұрын
Thank You Very Much can you do video for file upload API ? and Role-based routing?
@Iyexis
@Iyexis 5 ай бұрын
Hey, we're using cognito provider for authentication, is there a way to implement the same or similar solution for a custom form with a different provider?
@razonspielt1851
@razonspielt1851 9 ай бұрын
So i have a question, if I would make the same as you. Can I host it on a webhoster like hostinger in a shared hosting? Or do I need a vps? I ask this because this is my first next js project with auth js.
@theDStaten
@theDStaten 4 ай бұрын
i already have NextAuth configured for Google OAuth flow. Will the email & password setup from this video work with another OAuth provider being set up?
@michaelseaman7020
@michaelseaman7020 4 ай бұрын
Hello and thank you for your video! i have one issue. I cloned the code from the repo and it works fine, except in the userInfo component, it only displays the email. I could not get it to display any other properties. Thank you so much
@ProgrammerArif
@ProgrammerArif 10 ай бұрын
Great!
@A03L
@A03L 5 ай бұрын
I just subscribed :) Great content, easy and simple explanation I have a question tho, how do I hide that callback query in the url, its really annoying ... thanks
@uzmanalband9498
@uzmanalband9498 3 ай бұрын
I am trying to deploy this app to vercel, deployment is successful but unable to login
@programwithalex
@programwithalex 2 ай бұрын
hey thank you. you seemed like one of those random indian channels but you cantually have good content!
@patrickjreid
@patrickjreid 7 ай бұрын
Great video. is there a way to do this server side?
@altifyx_
@altifyx_ 4 ай бұрын
i want to place it in a other folder for example in a admin folder, so the login one directly in admin, but then register in a a register folder inside admin so it would look like admin/register. But then it doesn't work, what am i doing wrong 😅
@MabelEkemezie
@MabelEkemezie 10 ай бұрын
Pls I have I need your help after following up your work and I have deployed mine but I just saw myself in the home page Not even the sign in and login page what's wrong pls? I used netlify
@heisenbergcodm7380
@heisenbergcodm7380 9 ай бұрын
Hi Sir can you make the video on how to store the image from next js to mongodb and retreive the image from mongodb and display the image on frontend
@targettech2578
@targettech2578 9 ай бұрын
Nice work.. how about change and forget password
@redbeardjunior
@redbeardjunior 9 ай бұрын
I have one bug if I create a email & it exist, you will get the error it already exits if you create a second email after that it will not disappear but it wil create the email.
@abdullahkayhanlar3167
@abdullahkayhanlar3167 8 ай бұрын
Thanks for project, how to create a forgot password page?
@deepaknegi3940
@deepaknegi3940 9 ай бұрын
Can you please a video on how to use NextAuth and Next-intl together.
@rogertan2153
@rogertan2153 8 ай бұрын
i love mongodb all my homies love mongodb
@yellowsmurfz
@yellowsmurfz 10 ай бұрын
Thank you for this helpful video, will you make a follow up tutorial for adding tokens in your requests to the api and logging out the user if the token expires?
@GTCoding
@GTCoding 10 ай бұрын
Ok, I'll try.
@praiseoshilim1006
@praiseoshilim1006 9 ай бұрын
@@GTCoding handling refresh tokens too please?
@basitbaig
@basitbaig 4 ай бұрын
Hi, I need little help regarding session object null, i have follow this awesome tutorial and create a simple app, but after login the session always return NULL object at client but it shows object values at server console. Please help I am frustrated because it is about 3 days and I am stuck.... Thank you
@arshah246
@arshah246 8 ай бұрын
thanks alot great work. but i think its time for server action
@vsandhudeveloper3282
@vsandhudeveloper3282 9 ай бұрын
Can you please start an ecommerce series which include all concepts with mongo
@user-ez8on4ro8f
@user-ez8on4ro8f 8 ай бұрын
can anyone tell me the theme nsme he is using...?? please
@azamattugelbay
@azamattugelbay 7 ай бұрын
Can I ask how much is this safe? Can we use it in production projects
@1337sHADOWSTAR
@1337sHADOWSTAR 8 ай бұрын
how u make ctrl + d and change name, setName to password, setPassword and u change Password with big letters first word
@hills6940
@hills6940 9 ай бұрын
I guess the user's session should expire at some point due to inactivity. How can that be implemented?
@hamzapaskingakhtar
@hamzapaskingakhtar 5 ай бұрын
@1:02 When I add the imports in the login I get this error, TypeError: Cannot read properties of undefined (reading 'User') which is related to the models I don't understand what's the relation as it has nothing to do with the schema model in the login
@kiranmungekar8918
@kiranmungekar8918 4 ай бұрын
Hi Hamza, I am also facing same issue... did you find any solution on that?
@AnuragKumarVerma-eg4jc
@AnuragKumarVerma-eg4jc 2 ай бұрын
bhai page reset nhi ho rh koi help kro
@user-fr5qi3jz9n
@user-fr5qi3jz9n 3 ай бұрын
how to fix validation error in mongodb schema?
@developersplatform1132
@developersplatform1132 9 ай бұрын
can you deploy it into netlify
@TheDionysiac
@TheDionysiac 10 ай бұрын
Overall awesome video. But I'm a bit confused as to why we don't sign in the user after they register? At least I can't see anywhere in the source code where this happens.
@Tids_
@Tids_ 8 ай бұрын
it's normal practice to do it that way
@raduscortescu6512
@raduscortescu6512 7 ай бұрын
Normally, you have to validate the user by email confirmation, then you have to use the credentials to log in. That's the most secure way. You can have hackers attack your website and database if you can register and login automatically.
@luisjoselopezd
@luisjoselopezd 9 ай бұрын
if u are doin this, and the middleware does not work... try to put the file inside of "/src" just besides the folder "app".
@felipeespinoza985
@felipeespinoza985 9 ай бұрын
Thanks I needed it!
@Sebas-lk3jv
@Sebas-lk3jv 10 ай бұрын
thx
@TiredAndWearyTraveler
@TiredAndWearyTraveler 10 ай бұрын
hi, I am having trouble getting this to work on my side. i pulled from the github, did npm install, npm run dev, set up a mongo atlas server, created the .env and added the needed variables. I am able to register new users and can see them in the database, but when I try to log in with the email and password it does not do anything. it does not give any error either. did i miss a step, am i doing something wrong?
@JusTheWebDevNJIT
@JusTheWebDevNJIT 9 ай бұрын
yea im having the same issue its taken me hours and i cant figure it out. I've narrowed it down to the authorize function because the user is being returned incorrectly. Mine is only returning the email or nothing at all.
@Lixeann
@Lixeann 8 ай бұрын
​@@JusTheWebDevNJIT @dantedurant3412 Solution: Change secret to not a URL but a keyword like secret: 'test', and put it above the providers declaration, then it will work (tested myself)
@FRESHGAMENEWS
@FRESHGAMENEWS 7 ай бұрын
I got an error in components/UserInfo.jsx (8:38) @ useSession Error: [next-auth]: `useSession` must be wrapped in a How can i fix that? Is error because of using app directory?
@GTCoding
@GTCoding 7 ай бұрын
Make sure to wrap the content of the layout file with the SessionProvider. Here is the timestamp: kzfaq.info/get/bejne/hqt9mdaiv5iRcac.htmlfeature=shared&t=2851
@FRESHGAMENEWS
@FRESHGAMENEWS 7 ай бұрын
I looked for the error for 3 days and googled and could not find the solution. Now everything works! Thank you so much! @@GTCoding
@mikhacavin
@mikhacavin 9 ай бұрын
why not using typscript?
@prashlovessamosa
@prashlovessamosa 8 ай бұрын
Hello your sir can you please teach us some advance topics of NextJs.
@Honorato-Dev
@Honorato-Dev 9 ай бұрын
bro, how do I associate specific data with created users, so that only the user who uploaded his data can manage it in CRUD, as comments chat logic?
@user-iq2xr4kf1e
@user-iq2xr4kf1e 3 ай бұрын
hi, did you figure it out?
@SimarMannSingh
@SimarMannSingh 3 ай бұрын
I stumbled upon this video. I wish to provide a constructive feedback. I don't agree with using useState() hook at all for the login/register form. Everytime the value changes, it will cause a re-render of the component. This is a very inefficient way actually. Maybe you can also make another video highlighting this and improving on it. A better approach would imho be, to use the FormData(), populating it, instead of useState(). Many fellow developers have also pointed this out multiple times. Perhaps you can make a new version of this video?
@despo224
@despo224 3 ай бұрын
Why did you create a route to verify the user existing or not ? In the register route you are grabbing the user data sent by the client so why not just validate using the findOne({email:user.email}) and wrap that in a conditional in the try catch block and go from there.... Just want to hear your rationale because i know all developers think different.
@daugmaud
@daugmaud 8 ай бұрын
I'm using pages instead of app. How will the auth folder look like?
@GTCoding
@GTCoding 8 ай бұрын
/pages/api/auth/[...nextauth].js
@srkz
@srkz 3 ай бұрын
Error: [next-auth]: `useSession` must be wrapped in a
@varshigupta7399
@varshigupta7399 2 ай бұрын
i too got the same error but not able to resolve. please help me how to fix this issue.
@sina2706
@sina2706 4 ай бұрын
❤❤❤❤❤❤
@warriorking778
@warriorking778 9 ай бұрын
! important How to implement role based redirect. eg. for user has "/user" and for admin has "/admin". When I signin successfully then it will automatically redirect.
@spear5264
@spear5264 9 ай бұрын
Bro please make about next js 13 app directory
@mouhamedoussemarouis524
@mouhamedoussemarouis524 8 ай бұрын
good job, i have a question, how when u click on logout () => signOut() it redirected u to the home page ??
@GTCoding
@GTCoding 8 ай бұрын
In the route.js file of next-auth, I added the pages option and I have set the signIn to the homepage. Go to 46:58 of the video.
@hamzapaskingakhtar
@hamzapaskingakhtar 5 ай бұрын
@@GTCoding It is not redirecting for me. What could be the issue? I followed a to z
Next Auth Sign in With Credentials
14:51
Full Stack Niraj
Рет қаралды 131 М.
Универ. 10 лет спустя - ВСЕ СЕРИИ ПОДРЯД
9:04:59
Комедии 2023
Рет қаралды 922 М.
ГДЕ ЖЕ ЭЛИ???🐾🐾🐾
00:35
Chapitosiki
Рет қаралды 7 МЛН
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 63 МЛН
5 Tips and Tricks To Make Your Life With Next js 14 Easier
17:11
developedbyed
Рет қаралды 29 М.
How to make a QUIZ app with NO CODE
1:09
Glowbom
Рет қаралды 2 М.
React JS Explained In 10 Minutes
10:00
Dennis Ivy
Рет қаралды 236 М.
Next.js App Router Authentication (Sessions, Cookies, JWTs)
11:31
Универ. 10 лет спустя - ВСЕ СЕРИИ ПОДРЯД
9:04:59
Комедии 2023
Рет қаралды 922 М.