Build a Complete Sign-Up and Sign-In with Next.js, NextAuth, PostgreSQL, and Prisma

Sdílet
Vložit

Komentáře • 162

  • @ozgursar5386
    @ozgursar5386 Před 11 měsíci +15

    I think this is one of the most comprehensive tutorials that guides how to implement credentials provider using Prisma. Thank you!

  • @assad.rajab-2
    @assad.rajab-2 Před 3 měsíci +2

    Thank you very much, I have been looking for a long time for a tutorial that shows how to really create such a system with usernames and passwords. I even stopped a project because I couldn't find a solution for it. Now I have my passion back thanks to you.

    • @CandDev
      @CandDev  Před 3 měsíci

      Let's get back to coding 🧑🏻‍💻. Thanks for the tip

  • @gubatenkov
    @gubatenkov Před 9 měsíci +11

    Dude, this is the only one usefull tutorial about next-auth with prisma db, that i found on the internet !! Keep doing what you do

    • @assad.rajab-2
      @assad.rajab-2 Před 3 měsíci +1

      Yeah, litterly i have been searching for long time and i did not find anything, yet by accident i discovered this tutorial.

  • @foxhunt9305
    @foxhunt9305 Před 11 měsíci +9

    Great Video! I am a React developer and I just started messing around with Next.js and this project really helped me gain valuable knowledge about how Next.js works and the different tools available in the framework.
    One tip though: for security reasons it is better to have the id in the prisma model as a string and then set the default to uuid(), that way even if you dont have route protection someone cant just change the end of the route from number 1 to 2 for example and log in as the admin. instead the route will have something like this: 8624d47d-ceb0-4288-bd0a-876bb68985f0. which is a universally unique identifier that once generated can never be re-created so there is no chance of route manipulation in that way

  • @lydiabylicka4175
    @lydiabylicka4175 Před 4 měsíci +1

    I am halfway through the tutorial, encountered many errors (not the creator's fault - updates, installation, etc.) and I can say with certainty this is one of those tutorials I really want to follow through, it is so informative and just MAKES SENSE! Big kudos to you, @Cand Dev :)

  • @Ecki107
    @Ecki107 Před 7 měsíci +3

    The redirect after login at 43:00 can now also be implemented directly in the signIn-call. Just set redirect: true and provide a callbackUrl to which to redirect the user to.

  • @atifwattoo1719
    @atifwattoo1719 Před 4 měsíci +1

    That is the best tutorial on CZcams, related to authentication in Nextjs. Bro,, please make a complete course related to Nextjs in detail

  • @alwanassyauqi6191
    @alwanassyauqi6191 Před měsícem +2

    This is the tutorial I've been looking for!

  • @preciousnwaoha3123
    @preciousnwaoha3123 Před 3 měsíci +1

    I cannot remember any other coding tutorial that was as well done in terms of following up as this one. And I have been on this for years.

  • @cyrusrohail9243
    @cyrusrohail9243 Před 10 měsíci +2

    I looked up multiple tutorials. Only yours seemed to help me out of this hell hole called next-auth.
    Thank you!

  • @nikhilsharma2421
    @nikhilsharma2421 Před 8 měsíci +1

    Sir, this tutorial was really helpful you covered all the points. One more thing, I want to ask you can you please make a tutorial in which you're using both the credentials provider and also the google provider together. You can make that video in continue to this playlist.

  • @Noe_Sourdes
    @Noe_Sourdes Před 8 měsíci +1

    Have you released the next part of this series, incorporating Google authentication implementation? The series has been excellent so far! :)

  • @matiasleal7323
    @matiasleal7323 Před 10 měsíci +11

    github whit final code please

  • @Ms_Mariga
    @Ms_Mariga Před 9 měsíci +2

    Love Love Love this video. So simple and very informative. I followed along and learnt a lot. Thank you for this 😊.....
    Now the "Like so" is stuck to my head 😅

  • @pomiusu
    @pomiusu Před 4 měsíci

    this is the best nextjs tutorial I've seen, I always find difficult on following tutorials but this is the first that really helped me and I learned a lot of useful things, great work and nice didactic!!

  • @MustafaHasanKhan
    @MustafaHasanKhan Před 11 měsíci +5

    Hey, can you please give the final code Github repo. Thanks.

  • @loggerino7331
    @loggerino7331 Před 6 měsíci

    Great video dude. Your video is straight to the point unlike other youtubers who pad out their tutorials with unnecessary CSS stylings.

  • @Furki4_4
    @Furki4_4 Před 9 měsíci +1

    Thank you Cand! I was struggling to extend the session user data and i got the solution.

  • @user-ev4sq2io1c
    @user-ev4sq2io1c Před 9 měsíci

    Too good to believe, session are being introduced so well, why such good youtuber only have few people watch, what a lost for them.

  • @OnlyJavascript
    @OnlyJavascript Před rokem +3

    awesome. subbed. please continue this series. like role based auth. email verification. forget and reset password.

  • @davidabolade4708
    @davidabolade4708 Před 4 měsíci +1

    Brilliant, just brilliant

  • @enghimanshu
    @enghimanshu Před měsícem +1

    thansk alot i was crying from last night😭

    • @CandDev
      @CandDev  Před měsícem

      I'm glad I could help 😁

  • @myfavoriteai
    @myfavoriteai Před 8 měsíci +1

    "Fantastic! This video is like discovering a treasure trove. It's filled with invaluable insights. I'm convinced he's the best lecturer I've ever come across. Thank you so much. Your assistance has been instrumental in helping me create a practical, real-world product.

  • @bilalfaisalshaikh9165
    @bilalfaisalshaikh9165 Před 4 měsíci +1

    thanks a lot for this tutorial

  • @georgelopez6557
    @georgelopez6557 Před 9 měsíci +2

    Have you released the next part to this series, implementing google auth? Great series so far! :)

    • @CandDev
      @CandDev  Před 9 měsíci +3

      I have already uploaded that, but CZcams just deleted that video 😥.

    • @jami4588
      @jami4588 Před 9 měsíci +2

      @@CandDev upload it again we really need it

    • @UdaySagar
      @UdaySagar Před 8 měsíci

      @@CandDev can u pls try to upload the same video again ?

  • @user-bv5ne5sj5i
    @user-bv5ne5sj5i Před rokem +3

    This actually is awesome. you make it so simple Thank you. I would love you to make another video on role based access on top of this. 👌

  • @mounir101
    @mounir101 Před 9 měsíci +1

    Amazing video! all your videos are amazing and this one is clearly seen at another level. Thank u bro so much for charing.

  • @ichigokuro3986
    @ichigokuro3986 Před 9 měsíci +1

    itsthe final code available?
    my signIn() doesnt seem to execute the autorize function and i have no idea what im doing wrong.
    great tutorial btw!

  • @AnanthaGnaneswar21MIS702

    Bro is doing god's work. Thank you!!!

  • @muhammedgulcu
    @muhammedgulcu Před rokem

    You know how to write code very well and you explain it. Thank you very much 😎🙌👌

  • @nguyenat6454
    @nguyenat6454 Před rokem +1

    i really love how you give me the folder template to code and how you explain really really love the video. i hope u will make more videos about tricks and nextjs project 😊😊

    • @CandDev
      @CandDev  Před rokem +1

      and i hope you always support me, with like and comment 😁

    • @nguyenat6454
      @nguyenat6454 Před rokem

      @@CandDev i hope you will make a project with nextauth and other technologies ❤❤

  • @dalestewart
    @dalestewart Před rokem +1

    I love using PostgreSQL and Prisma

  • @AfaqAhmed-p9w
    @AfaqAhmed-p9w Před měsícem

    hy dear , i want to create otp section when user is register and login. please create otp verification video

  • @Amitsarker
    @Amitsarker Před 9 měsíci +1

    Excellent tutorial! Thank you

  • @brandonbailey4491
    @brandonbailey4491 Před rokem +1

    so what we if want to use a genuine backend for this instead? do we still need to use the next /api approach and then reach out to our api from there or can we just use fetch and session tokens in components?

  • @dalestewart
    @dalestewart Před rokem +2

    Another professional tutorial!👍

  • @adelmae9037
    @adelmae9037 Před 5 měsíci

    you did not include the api/ folders in your github repo why is that ?

  • @echovisionlab
    @echovisionlab Před 10 měsíci +1

    Great tutorial, inspired me a lot for making a tutorial.. :)

  • @thebeep4427
    @thebeep4427 Před rokem

    Sub so fast , great videos series bro , thank you so much !

    • @CandDev
      @CandDev  Před rokem

      Thanks for the sub! 🤍

  • @amogelangmoatswi1918
    @amogelangmoatswi1918 Před 10 měsíci +2

    am stuck at 44:51.. It doesn't redirect me to the Admin page even when the credentials are correct. please help

    • @user-yo9eu5wg9n
      @user-yo9eu5wg9n Před 10 měsíci

      я так сделал:
      auth.ts
      export const authOptions: NextAuthOptions = {
      adapter: PrismaAdapter(prisma),
      session: {
      strategy: 'jwt'
      },
      pages: {
      signIn: "/sign-in"
      },
      providers: [
      CredentialsProvider({
      name: "Credentials",
      credentials: {
      email: { label: "Email", type: "email", placeholder: "jsmith" },
      password: { label: "Password", type: "password" }
      },
      async authorize(credentials) {
      if (!credentials?.email || !credentials?.password) {
      return null
      }
      const existingUser = await prisma.user.findUnique({
      where: { email: credentials?.email }
      })
      if (!existingUser) {
      return null
      }
      const passwordMatch = await compare(credentials.password, existingUser.password)
      if(!passwordMatch){
      return null
      }
      return {
      id: `${existingUser.id}`,
      username: existingUser.username,
      email: existingUser.email
      }
      }
      })
      ],
      callbacks: {
      session: ({ session, token }) => {
      console.log("Session Callback", { session, token });
      return {
      ...session,
      user: {
      ...session.user,
      id: token.id,
      randomKey: token.randomKey,
      },
      };
      },
      jwt: ({ token, user }) => {
      console.log("JWT Callback", { token, user });
      if (user) {
      const u = user as unknown as any;
      return {
      ...token,
      id: u.id,
      randomKey: u.randomKey,
      };
      }
      return token;
      },
      },
      }

    • @omalaydrinks1847
      @omalaydrinks1847 Před 10 měsíci

      You are not alone. If you have solved it, let me know what you did to solve this problem.

    • @yoann590
      @yoann590 Před 9 dny

      @@user-yo9eu5wg9n thanks u are a legend !

  • @fernandocosta3307
    @fernandocosta3307 Před 4 měsíci

    Thank you man. I'm from 🇧🇷

    • @CandDev
      @CandDev  Před 3 měsíci +1

      Olá, Brasil 👋🏻

  • @harmiklathiya3625
    @harmiklathiya3625 Před 4 měsíci +1

    Where is the Signup flow ?

  • @user-oq3wt9rz8h
    @user-oq3wt9rz8h Před 5 měsíci

    Is this example basically safe to use in real website (with some additions)?

  • @adheichsan
    @adheichsan Před 9 měsíci

    I have an error in production mode in the sign out section, because when I click sign out, it still calls localhost, how can I make it not localhost anymore?
    🙏🙏🙏🙏🙏

  • @sylevan4116
    @sylevan4116 Před měsícem +1

    Hi Cand. When I run npx prisma migrate dev --name init. The terminal stands still and doesn't give any response. please help me!

    • @yoann590
      @yoann590 Před 9 dny

      Hey i have the same issue , did u find an answear for this problem ?

  • @codestudio497
    @codestudio497 Před 10 měsíci

    thank you , eveything is cool , but in my vscode everything is broken even the next auth page is updated , i can't get the default sign in page

  • @Glissadist
    @Glissadist Před 10 měsíci

    This series is awesome.

  • @aiscop
    @aiscop Před 8 měsíci

    Exactly what I was looking for🎉

  • @Osmanity
    @Osmanity Před 10 měsíci

    was very very happy until there was no source code in description... your provide it in other videos, please put it, awesome content

  • @TheWizardyGuy
    @TheWizardyGuy Před 8 měsíci

    Excellent tutorial, dude..! But, is there a tip to make this role based authentication? Btw don't forget to post nextauth authentication using google credentials.. 😊

  • @nami-san4642
    @nami-san4642 Před 17 dny

    25:02 if did use axios most efficient and less code!! over all i really like video

  • @nizomsidiq3
    @nizomsidiq3 Před 11 měsíci

    Thanks for the video! but how to implement throttling in the register API? and how to guard the pages to always redirect to login if user is unauthenticated?

  • @mendaxassange4465
    @mendaxassange4465 Před 8 měsíci

    can we have a video showing login + google auth + 2factor auth at the same time...?

  • @Engineer6nine
    @Engineer6nine Před 5 měsíci

    I am not able to singin.. it is redirecting me back to the home page..
    Showing warning about NEXTAUTH_URL and NEXTAUTH_SECRETKEY...
    someone please help

  • @amar5751
    @amar5751 Před 9 měsíci

    Hi can you add remember me functionality where my credentials Store in local storage and password should be encrypted...

  • @AleksandrNeo
    @AleksandrNeo Před 10 měsíci

    Thanks a lot! And how we can use API session? In others api`s reqests?

  • @xijicaijing
    @xijicaijing Před 7 měsíci

    Why the GitHub Repo codes not completly ?

  • @nobody2937
    @nobody2937 Před rokem

    Detailed and clear explaination...

  • @alibabadulan9911
    @alibabadulan9911 Před 10 měsíci

    I wonder if you have any tutor with progress bar with shadcn ui in future?

  • @yoann590
    @yoann590 Před 9 dny

    Hey Candid, i have an issue when i run npx prisma migrate dev --name init, the terminal stands still and doesn't give any response. Can you help me ?

    • @yoann590
      @yoann590 Před 9 dny

      I find the solution, the default port seems to not work (6543), i switched it on 5432 and its working now !

  • @tomich20
    @tomich20 Před 8 měsíci

    good video, it would be awesome if you create another branch on your project witht he final code!

  • @someoneelse4195
    @someoneelse4195 Před 11 měsíci

    After how much time a session is expired and can we manually set an expiry for session

  • @vitya.obolonsky
    @vitya.obolonsky Před 10 měsíci

    Next-auth does not work with custom forms

  • @Thikondrius
    @Thikondrius Před 10 měsíci

    Thank you for the video :) Can I ask where we can find the repo will the full code please ?

  • @ELMlKO
    @ELMlKO Před rokem +1

    at 43:17 when I click login it logs undefined and reloads even after I put redirect false and preventDefault

    • @samuelpalacios9661
      @samuelpalacios9661 Před 11 měsíci

      x2

    • @samuelpalacios9661
      @samuelpalacios9661 Před 11 měsíci +1

      Hey, I fixed it, i added the session provider hook from next-auth on the layout.tsx, also i add an try/catch block on the authorize in the authOptions

    • @codewithhaider7190
      @codewithhaider7190 Před 10 měsíci

      @@samuelpalacios9661 can you share the code i facing same issue

  • @abaydotdev
    @abaydotdev Před 8 měsíci

    great video mate!

  • @desuchanz4956
    @desuchanz4956 Před 11 měsíci

    stuck in signin authentication it says bad request

  • @Colt-tr6ec
    @Colt-tr6ec Před 10 měsíci

    amazing tutorial. Thank you!

  • @sebastiancastillo3560

    Amazing tutorial!! thanks so much🤩!

  • @mahmoodalfayoumi3429
    @mahmoodalfayoumi3429 Před 10 měsíci

    Great video! I was wondering if you had any idea how to make this expandable for multiple different logins. I am working on having two login pages with seperate admin pages, storing sign up data in two different prisma tables and using those to sign in. I managed to get the sign up post request to work, but my sign-in to redirect to the new admin page is causing me trouble that routes to me an error page. Any ideas?

  • @yuumeko_yt
    @yuumeko_yt Před 10 měsíci

    Can you update your source code please?
    there is no api folder and prisma folder. Just only forms?!

  • @gaminghub600
    @gaminghub600 Před 11 měsíci

    Can I use Next Auth in React Native Android Application??

  • @leesheppard7524
    @leesheppard7524 Před 4 měsíci

    Thanks for the video!

  • @kokusei9211
    @kokusei9211 Před 11 měsíci

    awesome tutorial very complete and easy to understand

  • @yoggyprastya
    @yoggyprastya Před 8 měsíci

    dude, how to implement this code for rest-api ?...
    regards..

  • @nomxxn
    @nomxxn Před 9 měsíci

    I dont get it, when did you create the forms and ui lmao, am i meant to create my own form or?

  • @omalaydrinks1847
    @omalaydrinks1847 Před 10 měsíci +1

    Is there any one who had challenge moving pass 44:56 - getting to admin page. If you did, i would like to know why it happened and how to solved it

    • @Jdsg1234
      @Jdsg1234 Před 10 měsíci +3

      Yes, add the following lines of code:
      In the SignInForm.tsx file, add a 'redirect: false' in the onSubmit function:
      so it would look like this:
      const onSubmit = async (values: z.infer) => {
      const signInData = await signIn("credentials", {
      email: values.email,
      password: values.password,
      redirect: false,
      });
      if (signInData?.error) {
      console.log("error----", signInData.error);
      } else {
      router.push("/admin");
      }
      };

    • @HadrianiOfficial
      @HadrianiOfficial Před 9 měsíci

      I tried myself as well, it does redirect me to the admin page, but it stays for 1 second and then it re-routes me back to the sign-in page. Putting the redirect: false, it will end up remaining on the sign in page, it doesn't lead me at all to the admin page. My issue is that on Application/Cookies, I don't get the "session" next-auth cookie....I only have the callback and the csrf-token@@Jdsg1234

  • @lucasgonzalez8313
    @lucasgonzalez8313 Před rokem +2

    Hey bro! nice tutorial! I'm stuck with the signIn part, because I'm having an issue after submit it redirect to /api/auth/error. Can you please help me with that? thanks :)

    • @Osmanity
      @Osmanity Před 10 měsíci

      did you solve it i have the same issue and are desperate to solve it

    • @Osmanity
      @Osmanity Před 10 měsíci +2

      I solve the redirect issue by chainging to the following code:
      "
      const signInData = await signIn("credentials", {
      email: values.email,
      password: values.password,
      redirect: false,
      });
      "
      in the signInForm.tsx file

    • @Osmanity
      @Osmanity Před 10 měsíci +1

      + other thing just look for my comment in the comment section of the video

  • @brayanjpm
    @brayanjpm Před 4 měsíci

    So useful bruh

  • @AkashLayal
    @AkashLayal Před rokem

    Can we host this on hostinger premium webhosting

  • @kitebeachinnbeachinn2888

    Awesome mate!

  • @diogomaia6636
    @diogomaia6636 Před 10 měsíci +1

    I'm getting a "Warning: Prop `htmlFor` did not match. Server: ":R2irb6qcq:-form-item" Client: ":Rabdcr9j9:-form-item" error when trying to log in. Tried to debug it but can't find the issue. Any help? ^^'

    • @Osmanity
      @Osmanity Před 10 měsíci

      got the same did you solve?

    • @lxespadatv2342
      @lxespadatv2342 Před 10 měsíci

      this htmlFor is just a warning from 1 of the shadcn components hes using in the starter template.. but i dont think thats causing your login error.. u manage to fix the error?

    • @Osmanity
      @Osmanity Před 10 měsíci

      @@lxespadatv2342 took some time but manage to fix it actually :)

    • @Osmanity
      @Osmanity Před 10 měsíci

      to fix this warning just look for my comment somewhere in the comments section, I think it was that you need to update nextjs & eslint

  • @amannambisan6870
    @amannambisan6870 Před 10 měsíci

    Great video!

  • @abylaikhanbaidullayev743
    @abylaikhanbaidullayev743 Před 10 měsíci

    Thank you for content, could you please explain where are you using "export const authOptions: NextAuthOptions"? I can't find it where are you using

    • @CandDev
      @CandDev  Před 10 měsíci

      i use that on my [...nextauth].js, app/page.tsx, navbar, and many more.

  • @odogru77
    @odogru77 Před 10 měsíci

    When I try to Login with the account I signed up for, I can't continue due to a 401 unauthorized error in the console. I guess it depends on the Credentials provider.

    • @user-yo9eu5wg9n
      @user-yo9eu5wg9n Před 10 měsíci

      я так сделал:
      в файл auth.ts добавил callback
      ],
      callbacks: {
      session: ({ session, token }) => {
      console.log("Session Callback", { session, token });
      return {
      ...session,
      user: {
      ...session.user,
      id: token.id,
      randomKey: token.randomKey,
      },
      };
      },
      jwt: ({ token, user }) => {
      console.log("JWT Callback", { token, user });
      if (user) {
      const u = user as unknown as any;
      return {
      ...token,
      id: u.id,
      randomKey: u.randomKey,
      };
      }
      return token;
      },
      },
      }

  • @qwertyzxvf6561
    @qwertyzxvf6561 Před 8 měsíci

    amazing video!

  • @DeveloperMan_
    @DeveloperMan_ Před 5 měsíci

    this is the type of youtubers i hide from my friends lol like hiding good shows

  • @AmanKumar-eg5rc
    @AmanKumar-eg5rc Před 11 měsíci

    In next js 13 app directory next auth we can not authenticate user without using prisma?

    • @CandDev
      @CandDev  Před 11 měsíci +1

      Yes, of course

  • @justin9494
    @justin9494 Před 11 měsíci

    you're much better than lamadev

    • @wowwolif9380
      @wowwolif9380 Před 10 měsíci

      I am new with both channels, but in which way he's better if you can explain

  • @doavers
    @doavers Před 8 měsíci

    Halo bang Cand.
    This is realy great tutorial. I watch the whole video but still got some issue. Can you please share the final code to us? Thank you..
    Mantap tutorialnya. Cuma ada issue ketika masuk ke halaman register kena redirect.
    Bisa minta final codenya bang.. Terima kasih.

  • @samuelmartinez7680
    @samuelmartinez7680 Před 2 měsíci

    where is the video with google login?

    • @CandDev
      @CandDev  Před 2 měsíci

      here: czcams.com/video/k1TL-AzavvY/video.htmlsi=gJXa-sF8jKcS7J9u

  • @Bobbaru
    @Bobbaru Před měsícem

    respect

  • @bale_1696
    @bale_1696 Před 11 měsíci

    Thanks you!!!!

  • @Grishopping
    @Grishopping Před rokem

    discord ????
    You won a new subscriber from Venezuela.... my English is bad but you explain very well.... I'm understanding
    Att. Jose Grillo

    • @CandDev
      @CandDev  Před rokem +1

      Thank you, my English is also not very good 😁, happy coding 👋🏻

  • @Kushal015
    @Kushal015 Před 11 měsíci

    I have tried twice my code is showing internal server error 500 can any one help me with it

    • @sifact1391
      @sifact1391 Před 11 měsíci

      restart your local server

  • @jami4588
    @jami4588 Před 9 měsíci

    i cant configure the nextauth credentials provider i tried everything but i am failing again and again even though i am correctly returning the user inside authorize and also i gave made my submit function correct everything is correct i dont know why is it still undefined the result that signIn is givng undefined always i do not know why is that happeing wasted ours in it searched it everywhere i logged the values of my email and pass that was correct but result from sign in is undeifned
    PLEASE HELP

    • @CandDev
      @CandDev  Před 9 měsíci +1

      Please send me your code, and I will check it.

    • @TheMorizzy
      @TheMorizzy Před 8 měsíci

      I had this same issue, try adding redirect: false to the object in the signIn function

    • @zuriagainigo7401
      @zuriagainigo7401 Před 8 měsíci

      Did you manage to fix it?

  • @ImamNurArifinHA
    @ImamNurArifinHA Před rokem

    nicee tutorial 👍

  • @ilahazs
    @ilahazs Před 8 měsíci

    Terimakasih bro ilmunya

    • @CandDev
      @CandDev  Před 8 měsíci

      makasih juga bro udah mampir

  • @muhardinhasim
    @muhardinhasim Před rokem

    kalau error Unexpected token } in JSON at position 121 kenapa ya ? padahal kodingnya secara step by step udah sama, udah coba search juga katanya minta downgrade efect di windows tapi coba di linux juga sama kenapa ya ?

    • @muhardinhasim
      @muhardinhasim Před rokem

      btw, aq kira bule, english keren hahaha

    • @CandDev
      @CandDev  Před rokem

      kemungkinan penempatan kurung kurawal yg salah, atau hilang.

    • @CandDev
      @CandDev  Před rokem

      masih belibet bro hahaha

    • @muhardinhasim
      @muhardinhasim Před rokem

      udah bisa thanks

  • @ruuma1074
    @ruuma1074 Před 10 měsíci

    3:32 itu pake apa bang? postgre gw ga kek gitu, apa karena mac?

    • @CandDev
      @CandDev  Před 10 měsíci +1

      iya, beda tampilan aja kayaknya. aku gak pernah coba juga sih tampilan selain di mac.