The Ultimate Guide to Next Auth - Everything You Need

Поділитися
Вставка
  • Опубліковано 22 жов 2024

КОМЕНТАРІ • 271

  • @codewithsam7300
    @codewithsam7300 Рік тому +2

    I am telling you this seriously. I have watched 20+ videos on UA-cam about the same. All the time things didn`t worked out. But today i completed your video and trust me on this, your tutorial is the best tutorial in the whole world. Just wanted to say you thank You friend............

  • @eshw23
    @eshw23 Рік тому +11

    Just found your channel and subscribed, i like how your tutorials are long and in depth about concepts to understand instead of just project tutorials, and i dont think 10 or 15 minute short videos can do the same.

  • @joe25x
    @joe25x Рік тому +18

    One of the best tutorials I have seen on UA-cam, you explained everything perfectly and in detail, looking forward to your next videos!

  • @adammo6661
    @adammo6661 24 дні тому

    Maaaan this literally saved my life. I was struggling to get both credentials with next auth working, but it does now. THANK YOU SOOOO MUCH

  • @hamzahahmad1670
    @hamzahahmad1670 Рік тому +2

    Hey Brett, I wanted to thank you for the very comprehensive video.
    Authentication is always a messy topic, and it's very appreciable how you explained not only credentials but also social login. Thanks again

  • @pablopenia
    @pablopenia Рік тому +1

    I did this hundred of times, but this is the first time I actually understand how it works. Thanks! you're a great teacher.

  • @shumit
    @shumit Рік тому +1

    Simply FABULOUS !!! THANK YOU SO VERY MUCH !!! I followed along. Perfect. You showed every nitty-gritty, were not too fast, not too slow, did not switch screens/windows suddenly (which confuses us, the beginners), were describing what you were doing, where you were doing, and why you were doing. Once more, THANK YOU !!!

  • @phil5293
    @phil5293 9 місяців тому +1

    Wow. Great video. I had to go through it twice to get everything right (I used typescript)

  • @agbaniglobal
    @agbaniglobal Рік тому +6

    You're an amazing teacher, and this is premium content. The way you explain every step makes it feel like a one on one class. Thank you!

  • @harshwardhanmore5877
    @harshwardhanmore5877 Рік тому +2

    you just saved my final year project man!!!! Thank You 1000 times

  • @ahasiakopian9696
    @ahasiakopian9696 Рік тому +3

    Thank you for the video!
    When registering, you need to block the form submit button after clicking, since you can spam the button and there will be many identical users in the database, you also need to add a check on the server when creating.
    Also, do not add your .env file to the repository. Now you have data that other users can use for authorization, be careful

  • @erickugel1376
    @erickugel1376 Рік тому +5

    WOW THANK YOU this really really helped it was super clear and easy to follow

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  Рік тому +1

      Thank you so much! I am glad you were able to follow my teachings easily! Thanks for tuning in and the donation!

  • @rafin_rahman
    @rafin_rahman 10 місяців тому +1

    the most comprehensive NextAuth tutorial, well done Brett!

  • @carafachera4781
    @carafachera4781 Рік тому +4

    Wow I just happily spend 5 hours watching and rewatching this video and I learned a lot. I don't know why I enjoyed some much. Thank Brett, you just earn a new loyal suscriber❤

  • @briandacallos4234
    @briandacallos4234 Рік тому +3

    You don't have no idea how much i need this, thank you. Clear and concise

  • @aubreyocallaghan4539
    @aubreyocallaghan4539 5 місяців тому +1

    Very useful. Appreciated showing both server and client auth

  • @BBocho
    @BBocho Рік тому +2

    Thank you very much, there are very few tutorials like this one implementing auth with the App Router, and it works perfectly fine!

  • @mattburgess5697
    @mattburgess5697 Рік тому +4

    This is a great and very helpful video, going through several different ways of logging in a user. Just one thing though… it’s not Prism. It’s very clearly PrisMA.

  • @sahaneakanayaka3394
    @sahaneakanayaka3394 Рік тому +4

    The best tutorial I found so far about Next 13 authentication. Everything was explained clear. Thank you so much ...🙏😍😍

  • @hadirahal5403
    @hadirahal5403 Рік тому +3

    Your channel deserves more attention!
    10/10 explanation!

  • @chesscom-z1o
    @chesscom-z1o Рік тому +1

    Good job sir really impressive content. Thank you very much for sharing.
    1. On a purely cosmetic side, in the login page, instead of the h1 "Sign into Github below" , I would rather change the button label to "Sign into Github". Same goes true for Google.
    2. Are you planning to add a "reset forgotten passwords" functionality, since this is the "Ultimate" guide ?
    Best regards.

  • @tworzymy_historie
    @tworzymy_historie 9 місяців тому

    I think this is what i need to be mid after almost 2 yers of commercial work and more years hobby coding ;)
    Ty!

  • @raymondmichael4987
    @raymondmichael4987 Рік тому

    Was scratching my head for this, using both credentials and social medias. Dude you just killed it, watched from zero to last seconds. Time to fight with TS into it 😊
    Thanks buddy, thanks a lot ❤
    Greetings from Tanzania 🇹🇿

  • @isaachatilima
    @isaachatilima Рік тому +1

    My search is over. Thank you Brett, great session

  • @semajroyam3725
    @semajroyam3725 Рік тому +1

    this is what I've been looking for after the update of nextjs, now i can implement this to my capstone project, thank you for this tutorial!

  • @waqaskhandev
    @waqaskhandev Рік тому +1

    Really Awesome walk through for the Next Auth. Learned alot. Thanks

  • @diamondpro2093
    @diamondpro2093 Рік тому +4

    Hey, love the videos. They are really helpful and concise. I was wondering if you could possibly make a video on what changes would have to be made to the application when its being pushed into production (i.e. changing specific environment variables, etc)

  • @mubashirwaheed474
    @mubashirwaheed474 Рік тому +2

    Thanks you so much for this video. Can you please make video on role based authentication?

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  Рік тому +1

      No problem! And yes I can take a look into that, so something like admin login, user login, etc? protecting routes?

    • @mubashirwaheed474
      @mubashirwaheed474 Рік тому

      @@brettwestwooddeveloper I have come across simple role based authentication videos but not ultimate guide per say.
      Role based authentication of user and admin using mongodb, prisma and next-auth. The major point of learning can be how to secure pages and then give access to certain routes only to the admin .
      For example: home and dashboard should be a protected route but only admin can access the dashboard.

  • @abhask01
    @abhask01 2 місяці тому

    watching after 1 year but thanks bro learned a lot

  • @joshuaekeh3775
    @joshuaekeh3775 6 місяців тому

    Thanks Brett. Your tutorial is quite easy to follow. You've made very simple.

  • @mahmoua07
    @mahmoua07 Рік тому +1

    This is a great explanation of next-auth , thank you brother.

  • @adrianhansa7018
    @adrianhansa7018 Рік тому +1

    Great tutorial, Brett! I am glad I found your channel. Thanks!

  • @kathirmldata7411
    @kathirmldata7411 Рік тому +1

    crystal clear explanation. easily understanding even for non English speaking country. thanks man. more love from india

  • @Shubham-yc6nz
    @Shubham-yc6nz Рік тому +1

    Best video on Internet. The latest greatest. I was bit confused about implementation using app/ directory thanks!!!

  • @CaseStudyQB
    @CaseStudyQB Рік тому

    Great video. Great job explaining each step and also showing how the network side of things looks in the browser console/tools. Thanks so much! I just subscribed!

  • @mediacreatif
    @mediacreatif Рік тому +1

    In the async authorize(credentials) function, I would fetch an API login. It's more clear for me. There is an API to register and there is an API to login.

  • @ahmetsakrak
    @ahmetsakrak Рік тому

    It's a truly informative and well-made video. I still have two lingering questions. First, what difference does it make in the underlying operation of Next Auth if we don't specify 'jwt' as a strategy? Second, why didn't you touch upon the topic of Middleware? It's crucial for user experience.

  • @samuelpalacios9661
    @samuelpalacios9661 Рік тому +1

    Hey Brett, amazing tutorial, one question, why you dind't use the Session model that next-auth provides as a starter code for prisma schema? (I guess its because that if we use jwt, the sessions will not be saved on the db)

    • @younkezenger8117
      @younkezenger8117 3 місяці тому

      As a beginner, I am also struggling on understanding the difference between this two models. Need some help to understand why choose one or another

    • @samuelpalacios9661
      @samuelpalacios9661 3 місяці тому

      @@younkezenger8117 Session only is used when you implement google/github auth options, so instead of only creating a user you also create a session. Hope this helps

  • @mbaochachigozie1785
    @mbaochachigozie1785 Рік тому +1

    By far the best nextAuth tut

  • @goldmikanik8274
    @goldmikanik8274 Рік тому

    Thank you for the explanation, just a question please, when user register he actually doesn't get auth cookies, he needs to signin after that to get them right?
    If yes, is there a way to tweak that, would be nice if user can register and start using his dashboard for example. Thank you again.

  • @rod6722
    @rod6722 11 місяців тому +1

    Curious why you didn't use the session model? As is suggested in the Next Auth docs on the Prisma adapter.

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  11 місяців тому

      Should have for tutorial purpose. But either way is fine. Definitely recommend using the adapter.

    • @ronokoushique7434
      @ronokoushique7434 9 місяців тому

      @@brettwestwooddeveloper I don't understand why it's not working automatically when I am using the adapter. Should I have to change anything for the session table to get populated automatically? plz help

  • @KkrDs97
    @KkrDs97 Рік тому +1

    This is Exactly what i am looking for and great explanation from you, Thank you.

  • @Leesdjo
    @Leesdjo 5 місяців тому

    Very detailed video. Thank you so much.

  • @Jerac07
    @Jerac07 Рік тому +1

    Great tutorial!!! One of the best I've seen. Quick question : How would you make an admin account that would see all other account is some sort of table?

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  Рік тому +1

      thank you! and you would have to create a custom value for admin signups through the login functionality. I would have to look into it more, and when I get good with it I can create a video on that topic. That is a very good topic that would be helpful!

    • @Jerac07
      @Jerac07 Рік тому +1

      @@brettwestwooddeveloper thank you alot. That would be super helpfull. Keep up the good work and all the best from Zagreb, Croatia!

  • @movocode
    @movocode 10 місяців тому +1

    Thank you for the tutorial.

  • @henrymunoz2035
    @henrymunoz2035 Рік тому +1

    Love it great work, thank you so much

  • @ozgursar5386
    @ozgursar5386 Рік тому +1

    Thank you for the nicely structured and detailed tutorial. I just couldn't understand how the signin to OAuth providers created the Account and User documents in mongodb.

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  Рік тому

      My most recent videos go more in depth about session data/object. I would recommend console logging profile, user, session and all to see what data you get back

  • @jamesnelson174
    @jamesnelson174 Рік тому +1

    Honestly, this guy is dope. I love this tutorial. ❤❤

  • @StartNight-df3sv
    @StartNight-df3sv 7 місяців тому

    Excellent tutorial.
    Unfortunately its not completed without JWT token option.
    Btw, you must modify your system environment for UA-cam tutorials.
    I mean your display resolution must not exceed 1080 HD
    Now all your screen texts are very tiny and makes a lot of eye strain.

  • @lostinthenarrativve
    @lostinthenarrativve 4 місяці тому +1

    Hey man, which of these videos should I watch first, this or the one that's titled "Nextauth credentials provider" ?

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  4 місяці тому

      I would watch this one first because it goes over everything. There is a new version of Next-Auth which is in beta. However, you can still use this video as a guide and is still relevant. I have other videos as well on my channel going over the session object and much more!

  • @OnlyJavascript
    @OnlyJavascript Рік тому +14

    at the end ..TS will get compiled to JS. that's browser's language. TS is like wearing armor while you eat breakfast. don't worry, i don't spill.

  • @leviathanxid
    @leviathanxid Рік тому +1

    Thankyou so much sir ,this video is really helped me

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  Рік тому +1

      No problem! Thank you for watching my video! Don't forget to hit that subscribe!

  • @codePerfect
    @codePerfect Рік тому +2

    Loved the tutorial

  • @R6videos6R
    @R6videos6R Рік тому

    Wow, you resolved my problem. Anywhere in the documentation was the error handling with the callback.ok and callback.error

  • @chriseski
    @chriseski Рік тому +1

    Like and subscription earned as deserved! Thank you Brett, awesome tutorial!

  • @kamilwitek8434
    @kamilwitek8434 Рік тому +1

    Hi Brett, why on folder name u put [...nextauth] - in js that is the way to copy array but don't understand why do we name like that folder

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  Рік тому +1

      it's called a catch all route when named like that. This allows you to run multiple API requests from that folder

  • @lamechamalisrael
    @lamechamalisrael 7 місяців тому

    Unfortunately, this isn't EVERYTHING I need. What I need now is to know why the adapters work in the development environment. But when I upload it to AWS Amplify, I cannot use the JWT to sign in any longer.

  • @merumeruedit
    @merumeruedit Рік тому +1

    Ty for your good tut i have a question what plugin you use that show auto complete before coding?

  • @devsspace1918
    @devsspace1918 Рік тому +1

    Thank you for sharing this insightful video.

  • @huyphamminh6911
    @huyphamminh6911 Рік тому

    i have a question, when you log in, next auth give you 3 tokens (next auth handled it), but how about when you sign up, you sent back user object via json, so we cant get the session when you sign up right

  • @jenniferjohnston9236
    @jenniferjohnston9236 Рік тому +1

    great tutorial! you should do one of these with next-auth-sanity

  • @mayukhhazari7820
    @mayukhhazari7820 Рік тому +1

    Incredible brother 🙌🙌

  • @TharuxYT
    @TharuxYT Рік тому +1

    one of the best tutorials I've seen

  • @jesustzinon
    @jesustzinon Рік тому +1

    If is not too much to ask, can you expand these series of videos of auth by adding password recover and normal and admin user roles?

  • @owenwijaya108
    @owenwijaya108 Рік тому +1

    this is fucking gold, you earned an instant subscriber!

  • @yongsujeong7870
    @yongsujeong7870 Рік тому +1

    This is the best tutorials I have seen on UA-cam Awesome! Could you tell me the reason why we need to add "/test" url at the end of the DATABASE_URL? Thank YOu!!

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  Рік тому

      thank you for the compliment and technically you can have whatever name you what instead of test. This will be your collection name in mongodb

    • @yongsujeong7870
      @yongsujeong7870 Рік тому

      @@brettwestwooddeveloper Really appreciate your answer!! Have a wonderful day!!!!😄😄

  • @skyMedia011
    @skyMedia011 11 місяців тому +1

    After route protection, when I write the login route manually in the search bar, it will show the login page for a while and then disappear which is not a good user experience.

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  11 місяців тому

      If you are calling the user on the client side with the useSession hook. Then it will cause that. You must fetch the user on server with the getServerSession. I am assuming you are calling the session client side?

    • @skyMedia011
      @skyMedia011 11 місяців тому +1

      @@brettwestwooddeveloper
      Yes I am using in client as my compo is in client side.
      Do you have any repo or a blog post about it ?

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  11 місяців тому

      no I don't but you will have to refactor your code so your page is a server component and then fetch the session on the server. Then any client components necessary. Impot them into the server page. Does that make sense?
      @@skyMedia011

    • @skyMedia011
      @skyMedia011 11 місяців тому

      @@brettwestwooddeveloper
      Thank you for the help.
      I got it and just solved ..

  • @mediacreatif
    @mediacreatif Рік тому +1

    For security purpose, you should not return the hashed password in the API register code. Just return the name and the email.

  • @reynaldobocaling4200
    @reynaldobocaling4200 7 місяців тому

    Please another tuts about next js with typescript, thankyou brother❤

  • @mryoung205
    @mryoung205 Рік тому

    i loved this ... and i added next auth to my project. but i still dont know how to protect a sever side page... i am getting error in my seversideprops

  • @sguitas
    @sguitas Рік тому +1

    This helped me a lot, thanks. Very clear explanation

  • @Adrian-mu8gg
    @Adrian-mu8gg Рік тому

    did i miss where the app is going to handle resetting password for credential provider? do you hv a tutorial on how to do that, and to assign role?

  • @TBDfilesLalit_kalyan
    @TBDfilesLalit_kalyan Рік тому

    thankyou so much for this tutorial ......kaap doing

  • @rohan_06
    @rohan_06 Рік тому +2

    I'm not able to log in with google, I'm getting "Try signing in with a different account." this error message. How can I approach this problem? can anyone help

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  Рік тому +1

      could be multiple reasons, inside of the google console where you set up the oAuth, make sure you entered the correct Redirect URI. If that is correct, then make sure your google client id and secret is correct. If that is fine, make sure your [...nextauth] route is probably set up with no errors.

    • @younkezenger8117
      @younkezenger8117 3 місяці тому

      I got the same error and then I noticed there is a spelling mistake in my Prisma schema

  • @BenLamptey
    @BenLamptey Рік тому +1

    Hey Brett, I've seen other tutorials where "mongoose" is used. I'm new to react/next etc...am I right in saying "mongoose" and "prisma" help setup schema's ? so we can use one or the other? if this is true, whats the benefits of using prisma ?

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  Рік тому +1

      Yes correct, I have seen ways that you can use mongoose and don't have to use prisma. Just a preference when it comes to coding

    • @BenLamptey
      @BenLamptey Рік тому

      @@brettwestwooddeveloper ah okay I see. Thanks for the quick reply.

    • @nicolaichristensen6531
      @nicolaichristensen6531 Рік тому

      Mongoose is a false layer of security, it gives no benefits apart from abstraction of the default mongodb sdk. You can send whatever the frick you want to your mongodb, and that's not ideal, so SQL is usually better than Mongodb. When I say usually, I mean 99.99% of the times.

  • @Dhanushsaji
    @Dhanushsaji 5 місяців тому +1

    I think for protected route we should use middleware page

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  5 місяців тому

      Yes ideally you should, but you can use it on individual pages as well if you want per the documentation.

  • @K0stur
    @K0stur Рік тому +1

    Idk if someone else asked... I don't know much about Prisma, but is there a reason ti pick it over Mongoose? I thought Prisma is more suited for SQL db's. I just started the vid but this seems like it is what I was after.

  • @daniyalfarooq998
    @daniyalfarooq998 Рік тому +1

    why cant i get fields other than name , email in the session? i tried returning user object with a field of Contact from [...nextauth] page too. but it is not carried into home page. btw Thanks for such a comprehensive tut. :)

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  Рік тому +1

      Thank you for tuning in, and by default you only get the name and email in the session. You must use the JWT strategy and then pass the data through the jwt to the session using asyn callbacks. I have a video on this: ua-cam.com/video/bkUmN9TH_hQ/v-deo.html

    • @daniyalfarooq998
      @daniyalfarooq998 Рік тому

      i have been using this procedure for some apps but now i have been facing an issue. The signup with google isnt working directly in api/auth/signup unless i remove the // adapter: PrismaAdapter(prisma) line in nextauth route. The signin with google isnt working at all from the login page in (site) folder. If there are any changes we should do then itll be really great because i have tried alot of stuff but nothing worked out for me. Youre a great teacher :)@@brettwestwooddeveloper

  • @AlfredLotsu
    @AlfredLotsu Рік тому +1

    this is so sick bro thank you

  • @madanmalhotra
    @madanmalhotra Рік тому

    Our next PM will be 👉👉Brett 👏

  • @fixesdev
    @fixesdev Рік тому +1

    Hi, nice video btw! Im very thankfull! One doubt, in the object of useSession i am not receiving and status key? is there a reason for that?

    • @fixesdev
      @fixesdev Рік тому +1

      nevermind, i got it!

  • @MrKeliv
    @MrKeliv Рік тому +1

    I love your video. I want to ask about protect the page with user has not been authenticated ?
    How to do that ? Thank you

    • @brettwestwooddeveloper
      @brettwestwooddeveloper  Рік тому +1

      Thank you and you just have to create a middleware file on the root of the whole project. export { default } from "next-auth/middleware"
      export const config = { matcher: ["/dashboard"] }
      This protects the dashboard page

    • @MrKeliv
      @MrKeliv Рік тому

      @@brettwestwooddeveloper Ok thank you. I already watch in another video. It has two option server side or client side. Glad to watch your video and help

  • @johndeer8405
    @johndeer8405 Рік тому +1

    Hi, can you do a really short video showing us how to setup a DELETE api route handler with and without prisma or at least with prisma. The new way in next13(app) is a bit confusing. Thanks for the content!

  • @silviojava96
    @silviojava96 Рік тому +1

    Great tutorial, but i'm getting this error:
    Error parsing attribute "@default": The current connector does not support the `auto()` function.

  • @dhavalbhimani1952
    @dhavalbhimani1952 6 місяців тому

    Bro great video but I want to learn more about middleware stuff with google provider. Please help with that

  • @yasserhy
    @yasserhy Рік тому +1

    I want to plzzzz ask u a question. How can I use NextAuth with Google to authenticate the user and then pass the session to NestJS project to authenticate the user there also so I can use the guards' features in NesfJS. There are no guides or tutorials about this at all

  • @17Kpa
    @17Kpa Рік тому

    If I need to bring me the user id and the roles, how would I do it? Great Video !

  • @Mike-ks7nr
    @Mike-ks7nr Рік тому +1

    at 25:41 when i try to sign in it gives me an error. Says: "Sign in failed. Check the details you provided are correct." But in inspector it has 302 Found

  • @codingcambodia
    @codingcambodia Рік тому +1

    Do you have a video using next-auth and role base access control,. Like basic , admin ... ?

  • @xouteiro0330
    @xouteiro0330 Рік тому +1

    Thank you for the great video, it helped a lot, but I have a problem regarding google auth, when I log in with google the first time and log out, the next time i try to login with google it automatically logs in with that account, it doesnt let the user choose another one
    I already tried a lot of things and nothing seems to work
    Thanks a lot again, great video!!

  • @hafsahussein2016
    @hafsahussein2016 10 місяців тому

    is there any way to prompt the custom errors in the register router? because something went wrong doesn't make sense, the user wants to know what is wrong.

  • @fadilarfat4974
    @fadilarfat4974 Рік тому

    can you make a continuation video of this to deploy, i got a trouble to deploy it all of the authentication is not working after i deploy it

  • @bengraham1798
    @bengraham1798 Рік тому +1

    Thank you 🙏

  • @0zankurt
    @0zankurt Рік тому +1

    Could you please make a video for laravel sanctum version of this?

  • @liveinorganic4542
    @liveinorganic4542 Рік тому

    Why I am getting error in axios.post('api/register, data) line when register. 'prisma.user.findUnique()' invocation. Please help

  • @basics-school
    @basics-school Рік тому +1

    Very good video..But dont we need to store the session in db?

  • @Septumsempra8818
    @Septumsempra8818 Рік тому +1

    What if we're using a backend API like django or springboot?

  • @PaarthJain-d1o
    @PaarthJain-d1o Рік тому

    Hey! Im using the same code in my project but when im connecting to the google provider, im receiving the data from google and getting the session as well, but somehow prisma is not storing my google account in Account model in the mongodb. Can someone help? I have looked to almost all possible error but cant figure it out!! Help would be appreciated

  • @emixj24
    @emixj24 Рік тому +1

    Good morning, does this work if I have the Front folder and the Back folder in two separate repositories? Since you are using files from the Back in the Front

  • @marmeladovsvid
    @marmeladovsvid Рік тому +1

    ty