Authentication with Next Auth and Next.js 14 | Protected routes, Server & Client Sessions

Поділитися
Вставка
  • Опубліковано 8 січ 2025

КОМЕНТАРІ • 88

  • @ansarqazi4377
    @ansarqazi4377 8 місяців тому +3

    The content is litreally so impressive. Everything is explained in quite simple way. Nothing extra in the video, just focusing on what actually needs to be done. Highly appreciated! Highly recommended! Thanks for the video.

  • @NoahCuz
    @NoahCuz 8 місяців тому +15

    Part 2 with updating the session on the server would be greatly appreciated! Subscribed

    • @webdevjan
      @webdevjan  8 місяців тому +4

      Part 2 is out now, have a look here: ua-cam.com/video/Aq4FstAD3iM/v-deo.html

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

    No BS guide to Oauth with a very minimal example , really great work

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

    Really appreciate this video. Quick and straight to the point, really helpful!

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

    Please a part 2 series !!! I like your style of tutorial. Thankssss

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

    Watched so many videos but couldn't get it. Your video had me setup in no time. Keep up the good work!

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

      That means so much! Glad I could help you out :)

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

    Sir, your demonstration is far better than others. Just an advice if you create a playlist where viewer can get all the auth/next.js related videos in one place that would be great

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

      I appreciate that so much. :)
      That actually already exists, have a look here:
      ua-cam.com/video/Cm6-3pVCPEI/v-deo.html

  • @maxwell-cj3ds
    @maxwell-cj3ds 3 місяці тому

    I really like this video and think it's one of the best for beginners. There are just two things I'd suggest: the video could be a little slower, and the sound should be louder. Other than that, everything is top-notch-your teaching skills and content are excellent. Thanks again for covering this topic in such a great way!

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

      Appreciate the valuable feedback! :)

  • @ansarqazi4377
    @ansarqazi4377 8 місяців тому +2

    Very useful content, quick, no time-wasting. Highly recommended! 🔥🔥🔥🔥

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

      Appreciate it bro!

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

    Thank you for this session
    really helped a ton!

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

    It would be great to see how to handle sessions for both cases (credentials and something like google) and with roles management off course.

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

    This is awesome tutorial.

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

    But with your approach in relation with SessionProvider wrappering all your application, are you losing any options of having server components? Because you are forced to use always components in client-side

  • @Twinkling-wy1dp
    @Twinkling-wy1dp 8 місяців тому

    Very useful content, thank you very much, solve my problem

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

    Thank you so much for this video... Can do one more about this and register User Data into MongoDB or any other database?

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

    In their documentation they say to make a file called [...nextauth].js but you are making a folder called that. Why the difference?

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

    It fixed my bug!! Thanks

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

    what is your extension that suggest that typescript errors in red color?

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

      Just saw this, sorry for the late reply. It's called "Error lens"

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

    how does your terminal autofill stuff, that's new to me!

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

    Can I know how we can get this nice background desktop ?

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

    Hi, do you have a tutorial that use only next.js with next auth without typescript ?

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

    Why do u using external services? I think custom auth will be there

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

    Just have a question. If Sessionwrapper is using use client and it's wrapping the whole layout won't this make the full app client side rendered? Since children would also follow csr. I'm very new to server rendering components in next js so please forgive my dumb question

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

      No, this has been asked a lot and I am one of them, lol. You can use chat gpt or Google to confirm.

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

    Yes nice, Question, what about I want to go to another page, if he is not log in, I want to show that page does not have accesss.. or redirect, do you do that in the middleware?

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

    Hi Man. Great content. Thanks. But I have a problem: I want to use session based authentication strategy (as you know jwt is little bit unsafe) and I also credentials provider. When I adjust credentials provider in auth.ts and other files, next auth throwing error something like " 'session': 'database' strategy doesn't support credentials provider" is there any way to fix it? if not, can you suggest me a library that allow users credentials login and uses session based strategy. What should I do? Thanks.

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

    i'm getting {"message":"There was a problem with the server configuration. Check the server logs for more information."} this when i host it in netlify don't know why

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

    that helps me a lot but the crazy thing is the vscode interface. can u please share the ur VS code profile file with me

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

    This is very good content and explanation, I really enjoyed it.
    However, I have a question there is a one second split delay where it shows the index page then the dashboard when logged in, is there a way to prevent this?

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

      You are performing the session check on the client with useSession which causes that delay. Perform the check on the server instead to avoid any layout shifts

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

      @@webdevjan can you explain more please?

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

    Subscribed, impressive stuff !! just on the point ♥♥♥

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

      Thank you so much

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

    What is the plugin you are using that shows the errors inline?

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

    really really helpful! thanks for sharing

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

      Glad it was helpful!

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

    very simple very helpfull. thank you.

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

    And if possible can you login using email and socials for appwrite with nextjs with both server and client. Please do it because no one UA-cam has done it properly

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

    So great! Thank you!

  • @sahebbeshra7659
    @sahebbeshra7659 8 місяців тому +1

    Ya we need part 2 with email and password and also save user in data base for google and github login

    • @webdevjan
      @webdevjan  8 місяців тому +1

      Part 2 is out now, have a look here: ua-cam.com/video/Aq4FstAD3iM/v-deo.html

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

    I want to give you a big thank you from France ! Do you have a discord server for your community ?

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

    thanks you brooo, tutorial is work

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

    mr. what authstrategy you used? is it jwt? local session? database session or other strategy? this nextauth makes me dying even premium chatgpt doesnt gave answer, i think learn trough experienced is still a better method

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

    const session = await getServerSession(authOptions);
    console.log("session", session);
    it don't work . session alway is null.
    can you help me? ple

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

      If the session is null, that means you are currently not logged in

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

    It works locally but in production gives me error 500

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

    Hi Yan , Followed your video, Amazing work and looking forward for new videos.
    Just needed to ask a question that while getting the session data on client side you've used useSession() , cant we use the same function on the server as well for getting the same session data ?

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

      Thanks! Once I have some free time, I'll definitely dive deeper into the nextauth series and create a part 2.
      In that, I'll explore the credentials provider and provide more in-depth information. :)
      The useSession hook is specifically designed for client components, meaning you can't utilize it on the server side.
      To address this limitation, nextauth introduced the getServerSession function, which performs the same task on the server.

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

      ​@@webdevjan Wow great, Now got the point. Thanks !! 😇😇

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

    Excelente vídeo! Parabéns!

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

    OK but you're just using localhost in your GitHub setup, that's not going to work in production so what's the point?

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

      change it to live when ready?

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

    idk why but i keep getting error 404 when clicking the button
    and the terminal shows this
    GET /api/auth/session 404 in 456ms
    GET /api/auth/session 404 in 32ms
    POST /api/auth/_log 404 in 32ms
    POST /api/auth/_log 404 in 15ms
    GET /api/auth/providers 404 in 44ms
    POST /api/auth/_log 404 in 40ms
    GET /api/auth/error 404 in 27ms
    and the session object is undefined

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

    I think the SessionWrapper wrapping everything at the top level, essentially makes everything a client side component so now your app is a SPA. Can someone else confirm this?

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

      I had the same thought... and the same lack of answer 😛
      Another video talking about a similar setup uses a slightly different approach inside layout.tsx to keep things server-side: ua-cam.com/video/md65iBX5Gxg/v-deo.html

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

      no it's not.

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

      ​@ashrafjunior3479 thank you for explaining

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

      If that would be the case, then you could use the useEffect (a client sided hook) for example in a fresh page.tsx file without specifying "use client" at the top. The wrapper is a server component so no need to worry about this :)

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

    Can you tell what extension is showing you errors directly in the code?

    • @webdevjan
      @webdevjan  7 місяців тому +2

      The extension is called "Error Lens"

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

    best tutorial

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

    Subscribed, impressive stuff !!

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

    Highly appreciate!

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

    Oh man, you saved my day.

  • @Plexify-v2s
    @Plexify-v2s 3 місяці тому

    I think you forgot the protected routes part

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

    part 2 ua-cam.com/video/Aq4FstAD3iM/v-deo.html&ab_channel=WebDevJan

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

    Thank you so much!!!!!

  • @BilalAmin-v5z
    @BilalAmin-v5z 7 місяців тому

    Thank you Jan

  • @shoaibshaikh0786
    @shoaibshaikh0786 8 місяців тому +1

    bro please upload part 2

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

      Part 2 is out now, have a look here: ua-cam.com/video/Aq4FstAD3iM/v-deo.html

  • @sungo9664
    @sungo9664 7 місяців тому +1

    I will have your Desktop Wallpaper please!!!

    • @webdevjan
      @webdevjan  7 місяців тому +1

      The wallpaper is called "Amazing Landscape" and I am using the program "Wallpaper Engine" from steam.

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

    Thanks bro

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

    du bist ne süße maus

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

    GoodJob!

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

    Ithinkitwasveryinteresting,hower,Igottiredinmyheadasyoudidmakeanynaturalpausesinyournarration.

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

      The video has jump cuts since most people have the attention span of a goldfish nowadays in this TikTok/short-form content era. If it wasn't cut down like this, a lot of viewers would just click away after 30 seconds.
      However, I appreciate your feedback.

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

      @@webdevjan Thank you for replying.
      May I suggest that you create and publish your videos in two versions: a short and a longer one and then provide a link for the short version in the long version and vice versa - a positive side effect of this is that you'll double your content with very little effort on your part.