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

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

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

  • @ansarqazi4377
    @ansarqazi4377 6 месяцев назад +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 7 месяцев назад +14

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

    • @webdevjan
      @webdevjan  6 месяцев назад +4

      Part 2 is out now, have a look here: ruclips.net/video/Aq4FstAD3iM/видео.html

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

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

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

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

  • @goodtimeswerehad
    @goodtimeswerehad 2 месяца назад +1

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

  • @ansarqazi4377
    @ansarqazi4377 6 месяцев назад +1

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

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

      Appreciate it bro!

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

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

      I appreciate that so much. :)
      That actually already exists, have a look here:
      ruclips.net/video/Cm6-3pVCPEI/видео.html

  • @maxwell-cj3ds
    @maxwell-cj3ds 2 месяца назад

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

      Appreciate the valuable feedback! :)

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

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

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

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

  • @bohdanromanovich4912
    @bohdanromanovich4912 21 день назад

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

  • @pescamuilesviavelez
    @pescamuilesviavelez 21 день назад

    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

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

    Thank you for this session
    really helped a ton!

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

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

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

    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

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

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

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

    Excelente vídeo! Parabéns!

  • @omarmohamedfaheem2198
    @omarmohamedfaheem2198 26 дней назад

    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  25 дней назад

      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 25 дней назад

      @@webdevjan can you explain more please?

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

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

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

    It fixed my bug!! Thanks

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

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

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

    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.

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

    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?

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

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

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

    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 RUclips has done it properly

  • @muhammadhuzaifaali3391
    @muhammadhuzaifaali3391 4 месяца назад

    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

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

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

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

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

  • @MysterYKnowledge621
    @MysterYKnowledge621 4 месяца назад +1

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

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

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

  • @Racine14
    @Racine14 5 месяцев назад +1

    This is awesome tutorial.

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

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

    • @webdevjan
      @webdevjan  6 месяцев назад +1

      Part 2 is out now, have a look here: ruclips.net/video/Aq4FstAD3iM/видео.html

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

    So great! Thank you!

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

    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 Месяц назад

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

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

    really really helpful! thanks for sharing

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

      Glad it was helpful!

  • @juventusi
    @juventusi 4 месяца назад

    It works locally but in production gives me error 500

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

    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

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

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

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

    very simple very helpfull. thank you.

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

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

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

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

  • @ashwinmanghat4416
    @ashwinmanghat4416 4 месяца назад

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

  • @Twinkling-wy1dp
    @Twinkling-wy1dp 6 месяцев назад

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

  • @Plexify-v2s
    @Plexify-v2s Месяц назад

    I think you forgot the protected routes part

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

    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 16 дней назад

      change it to live when ready?

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

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

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

      Thank you so much

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

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

      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: ruclips.net/video/md65iBX5Gxg/видео.html

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

      no it's not.

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

      ​@ashrafjunior3479 thank you for explaining

    • @webdevjan
      @webdevjan  Месяц назад +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 :)

  • @icisukacoding
    @icisukacoding 4 месяца назад +1

    thanks you brooo, tutorial is work

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

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

    • @webdevjan
      @webdevjan  6 месяцев назад +2

      The extension is called "Error Lens"

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

    Highly appreciate!

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

    best tutorial

  • @BilalAmin-v5z
    @BilalAmin-v5z 6 месяцев назад

    Thank you Jan

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

    Thank you so much!!!!!

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

    Oh man, you saved my day.

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

    Subscribed, impressive stuff !!

  • @sungo9664
    @sungo9664 6 месяцев назад +1

    I will have your Desktop Wallpaper please!!!

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

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

  • @shoaibshaikh0786
    @shoaibshaikh0786 6 месяцев назад +1

    bro please upload part 2

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

      Part 2 is out now, have a look here: ruclips.net/video/Aq4FstAD3iM/видео.html

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

    du bist ne süße maus

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

    Thanks bro

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

    GoodJob!

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

    part 2 ruclips.net/video/Aq4FstAD3iM/видео.html&ab_channel=WebDevJan

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

    Ithinkitwasveryinteresting,hower,Igottiredinmyheadasyoudidmakeanynaturalpausesinyournarration.

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

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

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