Custom Login Page in Next-Auth

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

КОМЕНТАРІ • 80

  • @vitezslavackermannferko7163
    @vitezslavackermannferko7163 Місяць тому

    Wow, I literally couldn't find any information how to use my own login form instead of the NextAuth provided and then found this video, which is even 10000% better! WOW!

    • @SakuraDev
      @SakuraDev  Місяць тому

      Thank you so much 🙏💖. I'm really glad that it was helpful for you 💖

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

    Its been two days watching your content and I must confess that you are the best tutor for nextjs

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

      Thank you so much for your nice words 💖

  • @NathanLewis-l6d
    @NathanLewis-l6d 11 місяців тому +1

    This helped me so much THANK YOU!!!!

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

      Thanks 🙏, I am really glad that it was helpful

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

    Amazing @Sakura Dev!! thanks a lot!

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

    Very nice video! Was wondering what would be the best setup to let users start on a sign up / sign in page and once user is authenticated the actual component tree loads

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

    Thanks for sharing Sakura.

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

    Thank you @Sakura Dev for Great Content. But i have a question that is how do we catch error exception incase lets say someone put wrong username or password.

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

      When an error occurs, we get back an error in the queryParam , and it is retrievable on the page props

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

      @@rockNbrain Thank you so much i will try that

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

    you explain documentation black holes really good

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

    Hi Sakura lovely to see the video. Very comprehensive, keep it up. Btw could create one for Drizzle ORM, PlanetScale, role based auth, credential login & email login?

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

      Hello there! Thank you so much for your kind words, I'm glad you enjoyed the video. I really appreciate your suggestions! Creating content about Drizzle ORM, PlanetScale, role-based authentication, credential login, and email login sounds like a great idea. I'll definitely consider these topics for future videos. Stay tuned for more comprehensive content, and feel free to reach out if you have any more suggestions or questions. Keep learning and exploring!

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

    Hi, thanks alot. how do I use it for custom registeration page? I get JWT token from backend when signing up

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

    Can you make the default home page is a landing page, and have role base auth in there? Like for crud or blog site but using all of this 😊

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

      Hey. I already have video on role based authorization, but yes In should create a new one. I will create it soon.

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

    How can I redirect to the login page based on the role for example if I am trying to access a admin page and I didn’t log in then redirects me back to the admin login page if i am training to access a user page and I didn’t login then redirect me back to the user login how can i do this, i create the login pages like you did using next-auth

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

      you can do it in next auth middleware. I have old video on that but I am going to create a new one. ua-cam.com/video/xJ6efexXJ7I/v-deo.html

  • @raimohaikari707
    @raimohaikari707 6 місяців тому +1

    What is the point of intercepting Login form?

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

      and what's the point on using a modal if it's still redirecting to the login page?

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

    Nice content dude .... I'm currently working in a side project using next 13 and next-auth ... but we have a separate backend written in golang ... I'm doing the google oauth flow and after success I need to send this data to the backend and it return our own jwt ... question... where is the best place to make this google backend sync .... currently im doing inside the jwt callback so I can pass all user obj adicional data and jwt ... is there any place in other callback maybe that it woul make more sense ? Because the only place that I've seen to chage the session obj is through jwt and session callbacks ..
    And please if possible make and project simulating an other backend so we can see if it changes a bit or have its nuances 🎉

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

      hey, 🖐🏻I think you can do it in the "signIn" event in next-auth route handler. this event will be called every time user signiIn successfully.

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

      @SakuraDev I did in the signIn callback in the first time but the problem is that in the signin callback, we can not mutate the user object (or can we?)... we simply return true or false if the user should continue the signflow ... the only place I saw I could mutate the user obj was using your strategy of combining jwt and session callback

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

      @@rockNbrain signIn "event" is different from callbacks. You can have events as well as callbacks.

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

      @@SakuraDev nice, tks a lot dude, I'll try to see the signIn event, I was actually only using signIn callback !

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

      @@rockNbrain 👍

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

    Could you try a combination of frontend nextjs while backend to be Django+django restframework

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

      Well, I am not a Django expert so I didn't think I can do it. 🙏🙏

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

      Its okay,no problem@@SakuraDev

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

    ❤❤❤❤❤

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

    Nice video bro keep up the good work. I got a question for you. I am stuck on this from quite a while now hope you can figure it out. I am using the next auth middleware to catch on the server if someone who's token is expired or does't have one and he is trying to access a private page should be redirected straight to login page (which contains only input fields nothing else) and that works perfectly, but since i am rendering the header on the client and i am using the next auth session there, once the user is redirected to login page the header does not dissapear immediately and there is a flicekr effect, also when you hit refresh and the page on which you are is SSR first it loads the page and after that the header shows up, since it's on the client.. Is there a solution for this i would be happy if you make a video on this topick, thanks

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

      Hey! 🖐🏻. Do you use custom login or using next auth default login?

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

      @@SakuraDev next auth login with credentials

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

      @@martindimitrov4696 yes that' why. you should create custom login page for next auth. in th video I explained how to do that.

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

      @@SakuraDev what about the second case?
      You hit refresh on a ssr page and page loads before header
      (header is conditionally rendered based on session)

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

    And what about protect the routes? I would like to protect the / page( root page) how can i do it?

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

      With next auth middleware we can do that. Thanks for watching👋

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

    Hey ! sakura, im trying to implement next14 with nextauth and cognito... any ideas of how can i do it ? Im stuck over here for weeks and I dont find any solution for the provider! I would be very appreciated if you give me a hand over here

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

      Well I don't have much experience with this stack but as far as I know you should handle that in authorize function of the next-auth provider

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

    Thanks again ❤

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

    Halo sakura, after login success my page redirect to dashboard, and on dashboard page i console.log using useSession and i get the token from next auth, but when i refresh the page on dashboard the console log useSession token to be null, can you help me this issue

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

      Hi, the first time you refresh the page, it returns null, but then it will update the session with appropriate value and re-render the page

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

    Thanks!

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

    Thank you

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

      Thanks

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

      And welcome to my channel

  • @csma212
    @csma212 Місяць тому

    Thank's for help

  • @yasinalbayrak2744
    @yasinalbayrak2744 8 місяців тому

    hello, how can i write my custom handler request? I want to add a new key under the session option in the next auth options according to the data from the post request, but it is not possible to do this without writing my own custom post request data because by default this way the data from the request is kept in the authorize provider.

    • @SakuraDev
      @SakuraDev  8 місяців тому

      Hey 👋, you should customize the next auth session type.

  • @nayandey5010
    @nayandey5010 8 місяців тому

    Thanks you sir, it really helped me

    • @SakuraDev
      @SakuraDev  8 місяців тому

      Thanks 🙏🙏🙏

  • @csma212
    @csma212 Місяць тому

    thanks a lot for help

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

    Here's one more subscriber

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

      Thanks for your support 🙏

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

    Hello everyone - I am trying to implement this, but when i set the pages object, signIn property, to '/signin', it redirects to 'api/auth/signin', not signin route at the app directory level. I think originally i had the object set to 'api/auth/signin' and then changed it, but the redirect isn't working after the update. anyone encountered this before or know what might be going wrong?

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

      Hey!, do use signIn() function or using a Link to navigate to login page?

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

      @@SakuraDev I used the signIn() function, and I am using the callbackUrl. I actually missed a key detail in my comment: I am using middleware to protect all pages, and when i set signIn: ‘/signin’ (at the app directory), it is trying to redirect to a route at api/auth/signin instead. I must be misinterpreting the docs or something. I have tested it and created a route at api/auth/signin, and it does redirect there, but for whatever reason I can’t get it to go to a route at the /app level. Hope that makes sense and appreciate the reply!

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

    Will this work with Auth JS beta?

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

    but you are losing the context, whats the point of the modal then? you are leaving the home

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

      Using parallel routes will fix that. Thanks for bringing that to my attention.

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

    how to handle locale ?
    my urls are "/locale/page"

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

    Thanks for sharing, nextjs nestjs please

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

      Oh yes with drizzle. I remember. expect it in my next video.

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

    Hi sir can you make a admin dashboard site with custom login page. Thank you

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

      Absolutely!. put it on my list

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

    tksssss

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

    why would i need 2 sign in page in my app?

    • @SakuraDev
      @SakuraDev  2 місяці тому +1

      We don't need 2 sign in pages. We just replace the first one

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

      @@SakuraDev ohh alright thanks

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

    Guys, modern approach to web development really sucks. That's should speed up process of development, but I just wasting a hours to learn such hipster abstractions