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

  Рет қаралды 90,789

GTCoding

GTCoding

Күн бұрын

Пікірлер: 181
@joshjakkrit6085
@joshjakkrit6085 3 ай бұрын
37:00 You don't have to create extra api route (userExists). All you have to do is set email unique: true in the schema. And update the same api route (register). const existingUser = await User.findOne({ email }); if (existingUser) { return NextResponse.json( { message: "Email already in use." }, { status: 409 } // conflict status ); } The form will display the message if you have this when (res.ok) = false const data = await res.json(); setError(data.message)
@BadrudeenAbdul-hameed
@BadrudeenAbdul-hameed 9 ай бұрын
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 5 ай бұрын
Only 2 days?
@aloukikjoshi
@aloukikjoshi 5 күн бұрын
Can you help me too?
@tomasburian6550
@tomasburian6550 8 ай бұрын
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.
@MisbahuA
@MisbahuA 6 ай бұрын
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 9 ай бұрын
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
@manzurajshahi
@manzurajshahi Жыл бұрын
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.😊
@HimanshuKumar-rn1cn
@HimanshuKumar-rn1cn 11 ай бұрын
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
@alokjoshi334
@alokjoshi334 Жыл бұрын
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 Жыл бұрын
Thank you :)
@JanBuilds
@JanBuilds Жыл бұрын
Thanks for the tutorial using javascript, not typescript! I have been looking for this for quite a while! :) 🙏🤓
@terry_swd
@terry_swd 6 ай бұрын
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.
@Salah-YT
@Salah-YT 6 ай бұрын
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!
@sagarvavadiya-gm2qd
@sagarvavadiya-gm2qd 2 ай бұрын
best explained next authentication concept; easy to understand
@onigbindedavid6630
@onigbindedavid6630 2 ай бұрын
This is ur second video i am watching, i love how u rlteach n create simple user interface
@patlagoon
@patlagoon 9 ай бұрын
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 ?
@Dekorozi
@Dekorozi Жыл бұрын
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 :)
@hakanaki
@hakanaki 10 ай бұрын
Thank you for this tutorial. Every other KZbinr is just doing login with Google SMH
@thefuturefounder
@thefuturefounder Ай бұрын
Bro God bless u I've been battling with this since since yesterday
@chiderathankgodobed4496
@chiderathankgodobed4496 11 ай бұрын
This is has to be the best tutorial i have seen in nextjs auth, thanks so much @GtCoding
@unu_levi
@unu_levi Ай бұрын
love this content from Korea bro! love it
@parspy694
@parspy694 10 ай бұрын
this is one of the best tutorial i've ever seen kudos to you sir
@sravankumar8763
@sravankumar8763 5 ай бұрын
Very good video, want to spend time and have my custom auth . you saved me a lot of lot of time
@Sam-hh3ry
@Sam-hh3ry Ай бұрын
why is this the only tutorial on this that seems to use normal code and not just a ton of 3rd party libraries to make it confusing
@toltec1983
@toltec1983 11 ай бұрын
best tutorial on the subject on yt.
@joakuvideo
@joakuvideo 11 ай бұрын
Impressive! I changed it a little bit for using prisma. :) thanks!
@fortuneoguibe5013
@fortuneoguibe5013 2 ай бұрын
This is gold!
@nxtalex10
@nxtalex10 5 ай бұрын
hey thank you. you seemed like one of those random indian channels but you cantually have good content!
@uzmanalband9498
@uzmanalband9498 6 ай бұрын
I am trying to deploy this app to vercel, deployment is successful but unable to login
@kbchannel83
@kbchannel83 6 ай бұрын
Thank You for this video, it's really helpful.
@amirhosseinqafari9747
@amirhosseinqafari9747 9 ай бұрын
Great, thanks for this solid tutorial.
@ezequieloliveira222
@ezequieloliveira222 6 ай бұрын
Muito bom bem explicado e simples, so achei esse e JS e não em Typscript
@kelechidaniel2281
@kelechidaniel2281 25 күн бұрын
I'm a beginner wonder the day I will be this good😔
@Mohamedkarms
@Mohamedkarms 10 ай бұрын
thanks a lot you are the besty one that explane this next auth thanks broo keep going 😃😁
@SimarMannSingh
@SimarMannSingh 6 ай бұрын
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?
@kevinthomas2406
@kevinthomas2406 Ай бұрын
very helpful ..Thank you
@Mascode
@Mascode 2 ай бұрын
You're the GOAT !!
@issa.garcia
@issa.garcia 11 ай бұрын
Nice content! So helpful, i really appreciate...Thanksss!
@codemelon2698
@codemelon2698 Жыл бұрын
this video is awesome keep up the amazing work
@Binod-km1xm
@Binod-km1xm 3 ай бұрын
Really Amazing Teaching❤❤
@byronloarte
@byronloarte Жыл бұрын
Great video and more content about Next.JS please my dear friend 🙏
@GTCoding
@GTCoding Жыл бұрын
Sure 👍
@leomeynard7671
@leomeynard7671 9 ай бұрын
Thank you, you explain it well.
@mrrafay2530
@mrrafay2530 10 ай бұрын
Good tutorial kindly also add role base authentication in this project
@leonardohurovich3381
@leonardohurovich3381 Жыл бұрын
Great video! Love it! Thank you sir
@afzaalahmedtai8211
@afzaalahmedtai8211 Жыл бұрын
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?
@PauloRdeOFerraz
@PauloRdeOFerraz 9 ай бұрын
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?
@zee_designs
@zee_designs Жыл бұрын
Straightforward approach 🦾
@piotrrodzen772
@piotrrodzen772 Жыл бұрын
great tutorial. Perhaps you could also add password system with JWT as I feel its much more secure in general
@judevector
@judevector Жыл бұрын
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
@adelinaakylbekova308
@adelinaakylbekova308 4 ай бұрын
Thank you for this tutorial
@tempuser9560
@tempuser9560 Жыл бұрын
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!
@raduscortescu6512
@raduscortescu6512 10 ай бұрын
Thanks, man! Simple great tutorial!
@沈天鱼
@沈天鱼 Жыл бұрын
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
@piodgamer4084
@piodgamer4084 4 ай бұрын
Thanks bro It's very good peace and love ^.^
@maplecountrywalk
@maplecountrywalk Ай бұрын
Thank you!
@nguyenlehuuduy6272
@nguyenlehuuduy6272 6 ай бұрын
Thank you immensely!
@joshbakit
@joshbakit 15 күн бұрын
I try to deploy to vercel with the correct steps but same error like SyntaxError: Unexpected token 'A', "An error o"... is not valid JSON and nextAuth Secret
@despo224
@despo224 6 ай бұрын
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.
@itksports
@itksports Жыл бұрын
Nice work.. how about change and forget password
@wolfie8748
@wolfie8748 2 сағат бұрын
I have (root) directory which I have daahboard etc can I forbid that so people will redirect to login or register if they are not authenticated in root layout
@karthikr5884
@karthikr5884 23 күн бұрын
Thank you ❤
@ManiSingh-gr7zi
@ManiSingh-gr7zi 6 ай бұрын
Thank you.
@rogertan2153
@rogertan2153 11 ай бұрын
i love mongodb all my homies love mongodb
@FRESHGAMENEWS
@FRESHGAMENEWS 11 ай бұрын
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 11 ай бұрын
Make sure to wrap the content of the layout file with the SessionProvider. Here is the timestamp: kzbin.info/www/bejne/hnawl6anj5dgd9Ufeature=shared&t=2851
@FRESHGAMENEWS
@FRESHGAMENEWS 11 ай бұрын
I looked for the error for 3 days and googled and could not find the solution. Now everything works! Thank you so much! @@GTCoding
@maskman4821
@maskman4821 9 ай бұрын
Great tutorial ❤
@Muhammadabubakar-k8t
@Muhammadabubakar-k8t 3 ай бұрын
sir the middleware logout button will not work its refresh and have on the same page dashbord page
@Hasoon-ry8pu
@Hasoon-ry8pu Жыл бұрын
Thanks for this video. Will you make a complete blog that brings together all the concepts?
@GTCoding
@GTCoding Жыл бұрын
Sure.
@A03L
@A03L 8 ай бұрын
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
@codigo6273
@codigo6273 11 ай бұрын
Thanks a lot for this video📌
@darshanathamara8546
@darshanathamara8546 Жыл бұрын
Thank You Very Much can you do video for file upload API ? and Role-based routing?
@Nanashi-rq7lk
@Nanashi-rq7lk Жыл бұрын
Thanks tutorial. your viedo is good.
@sarbeswarsahoo8579
@sarbeswarsahoo8579 Жыл бұрын
Thanks a lot for the video
@wayvroom
@wayvroom 10 ай бұрын
Awesome tutorial my brother keep it up ❤
@taukiralam414
@taukiralam414 11 ай бұрын
Man you are the best ..
@srkz
@srkz 6 ай бұрын
Error: [next-auth]: `useSession` must be wrapped in a
@varshigupta7399
@varshigupta7399 5 ай бұрын
i too got the same error but not able to resolve. please help me how to fix this issue.
@arshah246
@arshah246 Жыл бұрын
thanks alot great work. but i think its time for server action
@vsandhudeveloper3282
@vsandhudeveloper3282 Жыл бұрын
Can you please start an ecommerce series which include all concepts with mongo
@testing-jr8tz
@testing-jr8tz 7 ай бұрын
thanks man
@TheDionysiac
@TheDionysiac Жыл бұрын
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_ 11 ай бұрын
it's normal practice to do it that way
@raduscortescu6512
@raduscortescu6512 10 ай бұрын
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.
@deepaknegi3940
@deepaknegi3940 Жыл бұрын
Can you please a video on how to use NextAuth and Next-intl together.
@mijeongwon2355
@mijeongwon2355 11 ай бұрын
Thanks a lot!
@Ruben-sc7dj
@Ruben-sc7dj 11 ай бұрын
Thank you!:)
@heisenbergcodm7380
@heisenbergcodm7380 Жыл бұрын
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
@warriorking778
@warriorking778 Жыл бұрын
! 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.
Жыл бұрын
Thank you soo much
@MarcosFelipe-up9lc
@MarcosFelipe-up9lc 8 ай бұрын
Thanks bro!!
@hamzapaskingakhtar
@hamzapaskingakhtar 8 ай бұрын
@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 7 ай бұрын
Hi Hamza, I am also facing same issue... did you find any solution on that?
@surindersingh7799
@surindersingh7799 9 ай бұрын
great video :)
@michaelseaman7020
@michaelseaman7020 8 ай бұрын
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
@yellowsmurfz
@yellowsmurfz Жыл бұрын
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 Жыл бұрын
Ok, I'll try.
@praiseoshilim1006
@praiseoshilim1006 Жыл бұрын
@@GTCoding handling refresh tokens too please?
@prashlovessamosa
@prashlovessamosa 11 ай бұрын
Hello your sir can you please teach us some advance topics of NextJs.
@MabelEkemezie
@MabelEkemezie Жыл бұрын
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
@basitbaig
@basitbaig 8 ай бұрын
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
@razonspielt1851
@razonspielt1851 Жыл бұрын
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.
@yukiritosurada8392
@yukiritosurada8392 5 ай бұрын
please make an infinitely nested comments using nextjs and mongodb 🙏🙏
@hills6940
@hills6940 Жыл бұрын
I guess the user's session should expire at some point due to inactivity. How can that be implemented?
@theDStaten
@theDStaten 7 ай бұрын
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?
@ProgrammerArif
@ProgrammerArif Жыл бұрын
Great!
@hamzapaskingakhtar
@hamzapaskingakhtar 10 ай бұрын
Seems like its working for everyone but not for me. It is saying that my uri to connect to mongoDB should be a string and is getting undefined. Very strange.
@hamzapaskingakhtar
@hamzapaskingakhtar 10 ай бұрын
used .env.local instead
@redbeardjunior
@redbeardjunior Жыл бұрын
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.
@altifyx_
@altifyx_ 7 ай бұрын
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 😅
@abdullahkayhanlar3167
@abdullahkayhanlar3167 Жыл бұрын
Thanks for project, how to create a forgot password page?
@patrickjreid
@patrickjreid 10 ай бұрын
Great video. is there a way to do this server side?
The Joker wanted to stand at the front, but unexpectedly was beaten up by Officer Rabbit
00:12
Will A Guitar Boat Hold My Weight?
00:20
MrBeast
Рет қаралды 205 МЛН
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26
Protected routes in Nextjs 15 | Protect Routes with Middleware Nextjs
27:33
Next-Auth on App Router - Solid Auth, Super Fast
17:20
Jack Herrington
Рет қаралды 114 М.
Next Auth Sign in With Credentials
14:51
Full Stack Niraj
Рет қаралды 137 М.
Next.js Authentication || Register User To MongoDB With Next-Auth V5
35:23
tapaScript by Tapas Adhikary
Рет қаралды 9 М.
The Joker wanted to stand at the front, but unexpectedly was beaten up by Officer Rabbit
00:12