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

Поделиться
HTML-код
  • Опубликовано: 18 окт 2024

Комментарии • 182

  • @MisbahuA
    @MisbahuA 7 месяцев назад +2

    This is one of the best tutorials seen on Nextjs, mongoose and nextauth. Thank you good Sir, really appreciate your effort. Keep it up

  • @Salah-YT
    @Salah-YT 7 месяцев назад +2

    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!

  • @BadrudeenAbdul-hameed
    @BadrudeenAbdul-hameed 10 месяцев назад +7

    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.

  • @joshjakkrit6085
    @joshjakkrit6085 4 месяца назад +8

    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)

  • @tomasburian6550
    @tomasburian6550 9 месяцев назад +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.

  • @chiderathankgodobed4496
    @chiderathankgodobed4496 10 месяцев назад +4

    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

  • @HimanshuKumar-rn1cn
    @HimanshuKumar-rn1cn Год назад +1

    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 Год назад +7

    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.

  • @terry_swd
    @terry_swd 7 месяцев назад

    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.

  • @manzurajshahi
    @manzurajshahi Год назад +3

    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.😊

  • @JanBuilds
    @JanBuilds Год назад +2

    Thanks for the tutorial using javascript, not typescript! I have been looking for this for quite a while! :) 🙏🤓

  • @onigbindedavid6630
    @onigbindedavid6630 3 месяца назад

    This is ur second video i am watching, i love how u rlteach n create simple user interface

  • @Dekorozi
    @Dekorozi Год назад +1

    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 :)

  • @sagarvavadiya-gm2qd
    @sagarvavadiya-gm2qd 3 месяца назад +1

    best explained next authentication concept; easy to understand

  • @chiderathankgodobed4496
    @chiderathankgodobed4496 11 месяцев назад

    This is has to be the best tutorial i have seen in nextjs auth, thanks so much @GtCoding

  • @patlagoon
    @patlagoon 10 месяцев назад +2

    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 ?

  • @parspy694
    @parspy694 11 месяцев назад

    this is one of the best tutorial i've ever seen kudos to you sir

  • @unu_levi
    @unu_levi 2 месяца назад

    love this content from Korea bro! love it

  • @perspicaciousdev
    @perspicaciousdev 2 месяца назад

    Bro God bless u I've been battling with this since since yesterday

  • @hakanaki
    @hakanaki 11 месяцев назад

    Thank you for this tutorial. Every other RUclipsr is just doing login with Google SMH

  • @toltec1983
    @toltec1983 Год назад

    best tutorial on the subject on yt.

  • @sravankumar8763
    @sravankumar8763 6 месяцев назад

    Very good video, want to spend time and have my custom auth . you saved me a lot of lot of time

  • @zee_designs
    @zee_designs Год назад +1

    Straightforward approach 🦾

  • @fortuneoguibe5013
    @fortuneoguibe5013 2 месяца назад

    This is gold!

  • @amirhosseinqafari9747
    @amirhosseinqafari9747 10 месяцев назад

    Great, thanks for this solid tutorial.

  • @afzaalahmedtai8211
    @afzaalahmedtai8211 Год назад +1

    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?

  • @Binod-km1xm
    @Binod-km1xm 4 месяца назад

    Really Amazing Teaching❤❤

  • @kbchannel83
    @kbchannel83 7 месяцев назад

    Thank You for this video, it's really helpful.

  • @raduscortescu6512
    @raduscortescu6512 11 месяцев назад

    Thanks, man! Simple great tutorial!

  • @leonardohurovich3381
    @leonardohurovich3381 Год назад

    Great video! Love it! Thank you sir

  • @Mascode
    @Mascode 3 месяца назад

    You're the GOAT !!

  • @沈天鱼
    @沈天鱼 Год назад +1

    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

  • @codemelon2698
    @codemelon2698 Год назад

    this video is awesome keep up the amazing work

  • @joakuvideo
    @joakuvideo Год назад

    Impressive! I changed it a little bit for using prisma. :) thanks!

  • @maskman4821
    @maskman4821 10 месяцев назад

    Great tutorial ❤

  • @PauloRdeOFerraz
    @PauloRdeOFerraz 10 месяцев назад

    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?

  • @adelinaakylbekova308
    @adelinaakylbekova308 5 месяцев назад

    Thank you for this tutorial

  • @leomeynard7671
    @leomeynard7671 10 месяцев назад

    Thank you, you explain it well.

  • @Mohamedkarms
    @Mohamedkarms 11 месяцев назад

    thanks a lot you are the besty one that explane this next auth thanks broo keep going 😃😁

  • @Sam-hh3ry
    @Sam-hh3ry 2 месяца назад

    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

  • @SimarMannSingh
    @SimarMannSingh 7 месяцев назад

    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?

  • @uzmanalband9498
    @uzmanalband9498 7 месяцев назад +1

    I am trying to deploy this app to vercel, deployment is successful but unable to login

  • @A03L
    @A03L 9 месяцев назад

    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

  • @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.

  • @kevinthomas2406
    @kevinthomas2406 2 месяца назад

    very helpful ..Thank you

  • @AlexyMiro
    @AlexyMiro Год назад +1

    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 месяцев назад +1

      Make sure to wrap the content of the layout file with the SessionProvider. Here is the timestamp: ruclips.net/video/PEMfsqZ2-As/видео.htmlfeature=shared&t=2851

    • @AlexyMiro
      @AlexyMiro 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

  • @nguyenlehuuduy6272
    @nguyenlehuuduy6272 7 месяцев назад

    Thank you immensely!

  • @piotrrodzen772
    @piotrrodzen772 Год назад +1

    great tutorial. Perhaps you could also add password system with JWT as I feel its much more secure in general

    • @judevector
      @judevector Год назад +1

      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

  • @hamzapaskingakhtar
    @hamzapaskingakhtar 9 месяцев назад +1

    @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 8 месяцев назад

      Hi Hamza, I am also facing same issue... did you find any solution on that?

  • @Muhammadabubakar-k8t
    @Muhammadabubakar-k8t 4 месяца назад

    sir the middleware logout button will not work its refresh and have on the same page dashbord page

  • @issa.garcia
    @issa.garcia Год назад

    Nice content! So helpful, i really appreciate...Thanksss!

  • @joshbakit
    @joshbakit Месяц назад

    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

  • @byronloarte
    @byronloarte Год назад

    Great video and more content about Next.JS please my dear friend 🙏

  • @riadhallouch
    @riadhallouch 2 дня назад +1

    It's really bad wrapping the whole app inside a client component, this is basically React so no SSR.
    You can simply return the auth object, and fetch the session when needed instead of doing it this way!!

  • @theDStaten
    @theDStaten 8 месяцев назад

    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?

  • @wayvroom
    @wayvroom 11 месяцев назад

    Awesome tutorial my brother keep it up ❤

  • @Hasoon-ry8pu
    @Hasoon-ry8pu Год назад

    Thanks for this video. Will you make a complete blog that brings together all the concepts?

  • @mrrafay2530
    @mrrafay2530 11 месяцев назад

    Good tutorial kindly also add role base authentication in this project

  • @nxtalex10
    @nxtalex10 6 месяцев назад

    hey thank you. you seemed like one of those random indian channels but you cantually have good content!

  • @itksports
    @itksports Год назад

    Nice work.. how about change and forget password

  • @despo224
    @despo224 7 месяцев назад

    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.

  • @deepaknegi3940
    @deepaknegi3940 Год назад

    Can you please a video on how to use NextAuth and Next-intl together.

  • @wolfie8748
    @wolfie8748 27 дней назад

    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

  • @taukiralam414
    @taukiralam414 Год назад

    Man you are the best ..

  • @vsandhudeveloper3282
    @vsandhudeveloper3282 Год назад

    Can you please start an ecommerce series which include all concepts with mongo

  • @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!

  • @maplecountrywalk
    @maplecountrywalk 2 месяца назад

    Thank you!

  • @atharvmishra884
    @atharvmishra884 Год назад

    24:32 - 24:37 How did you do that??? 😳 to Type in Capitalcase on the first cursor position but in lowercase on the second cursor position?

    • @GTCoding
      @GTCoding  Год назад +2

      I am using a VS Code extension called 'Multiple cursor case preserve'.

    • @atharvmishra884
      @atharvmishra884 Год назад

      Thank you so much!! Thats awesome

  • @TheDionysiac
    @TheDionysiac Год назад +2

    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_ Год назад

      it's normal practice to do it that way

    • @raduscortescu6512
      @raduscortescu6512 11 месяцев назад

      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.

  • @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

  • @darshanathamara8546
    @darshanathamara8546 Год назад

    Thank You Very Much can you do video for file upload API ? and Role-based routing?

  • @kelechidaniel2281
    @kelechidaniel2281 Месяц назад

    I'm a beginner wonder the day I will be this good😔

  • @CodeMoto11
    @CodeMoto11 Год назад

    Thanks a lot for this 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?

  • @TiredAndWearyTraveler
    @TiredAndWearyTraveler Год назад +1

    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 Год назад +1

      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 Год назад

      ​@@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)

  • @basitbaig
    @basitbaig 9 месяцев назад

    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

  • @prashlovessamosa
    @prashlovessamosa Год назад

    Hello your sir can you please teach us some advance topics of NextJs.

  • @hills6940
    @hills6940 Год назад

    I guess the user's session should expire at some point due to inactivity. How can that be implemented?

  • @rogertan2153
    @rogertan2153 Год назад

    i love mongodb all my homies love mongodb

  • @karthikr5884
    @karthikr5884 Месяц назад

    Thank you ❤

  • @sarbeswarsahoo8579
    @sarbeswarsahoo8579 Год назад

    Thanks a lot for the video

  • @surindersingh7799
    @surindersingh7799 10 месяцев назад

    great video :)

  • @Nanashi-rq7lk
    @Nanashi-rq7lk Год назад

    Thanks tutorial. your viedo is good.

  • @abdullahkayhanlar3167
    @abdullahkayhanlar3167 Год назад

    Thanks for project, how to create a forgot password page?

  • @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

  • @ezequieloliveira222
    @ezequieloliveira222 7 месяцев назад

    Muito bom bem explicado e simples, so achei esse e JS e não em Typscript

  • @altifyx_
    @altifyx_ 8 месяцев назад

    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 😅

  • @srkz
    @srkz 7 месяцев назад +1

    Error: [next-auth]: `useSession` must be wrapped in a

    • @varshigupta7399
      @varshigupta7399 6 месяцев назад

      i too got the same error but not able to resolve. please help me how to fix this issue.

  • @shubhbham7878
    @shubhbham7878 Год назад

    Sir, why did you stop to upload videos in RUclips sir i am missing your tutorials ,can you please specify the new releases dates...
    .

    • @GTCoding
      @GTCoding  Год назад +1

      I am working on a new tutorial series. The first video in the series will be released in a couple of days.

  • @mijeongwon2355
    @mijeongwon2355 Год назад

    Thanks a lot!

  • @Ruben-sc7dj
    @Ruben-sc7dj Год назад

    Thank you!:)

  • @azamattugelbay
    @azamattugelbay 11 месяцев назад

    Can I ask how much is this safe? Can we use it in production projects

  • @MarcosFelipe-up9lc
    @MarcosFelipe-up9lc 9 месяцев назад

    Thanks bro!!

  •  Год назад

    Thank you soo much

  • @robeeeeen
    @robeeeeen Месяц назад

    No email verification in this day?

  • @1337sHADOWSTAR
    @1337sHADOWSTAR Год назад

    how u make ctrl + d and change name, setName to password, setPassword and u change Password with big letters first word

  • @ManiSingh-gr7zi
    @ManiSingh-gr7zi 7 месяцев назад

    Thank you.

  • @yukiritosurada8392
    @yukiritosurada8392 6 месяцев назад

    please make an infinitely nested comments using nextjs and mongodb 🙏🙏

  • @patrickjreid
    @patrickjreid 11 месяцев назад

    Great video. is there a way to do this server side?