The Easiest Way to add Auth to a Next App

Поделиться
HTML-код
  • Опубликовано: 5 июл 2024
  • Learn how to add auth to your next application using next auth and github login.
    Newer next auth video for next 14: • Effortless Auth in Nex...
    Code:
    www.sammeechward.com/the-easi...
    Next & Prisma: • Prisma & Next.js
    Next Auth & Prisma: • Next Auth and Prisma
    Join this channel to get access to perks:
    / @sammeechward
    Chapters:
    0:00​ Intro
    1:31 Setup Next Auth
    3:58 Setup Github Login
    6:05 Session Provider
    7:29 useSession
    11:00 unstable_getServerSession
    14:08 Restrict Pages
    15:50 Nav Bar
    17:17 Next Image
    19:12 Restrict API
    21:03 Summary
    🔗Moar Links
    My Website: www.sammeechward.com
    Instagram: / meech_ward
    Twitter: / meech_ward
    Github: github.com/orgs/Sam-Meech-Ward
  • НаукаНаука

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

  • @sohrabradmehrgaming1556
    @sohrabradmehrgaming1556 Год назад +1

    Best next auth video!

  • @dnial6992
    @dnial6992 Год назад +1

    I love this kind of contents! Keep it up idol! Wish you can make content in Angular.js also. Thanks for this lesson, appreciate it.

  • @mdraselkhan3125
    @mdraselkhan3125 Год назад

    Thank you. Like this video.

  • @jamesrobert5332
    @jamesrobert5332 Год назад

    Thanks once again for another great video man, You're a great help! Also an update: It's no longer experimental now. unstable_getServerSession is deprecated, getServerSession works perfectly now

  • @Chris...S
    @Chris...S Год назад

    Was hoping you included Microsoft Azure AD B2C. Hard to find a walk through on it.

  • @aprilm2941
    @aprilm2941 Год назад +1

    As a premium subscriber I approve of this video

  • @shattereddnb3268
    @shattereddnb3268 Год назад

    Great video! But I´m getting:
    "Server Error
    TypeError: Cannot read properties of undefined (reading 'getHeader')"
    from the getServserSideProps-function.
    I refactored with the new getServerSession like this:
    import { getServerSession } from "next-auth";
    ...
    export const getServerSideProps = async (req, res) => {
    const session = await getServerSession(req, res, authOptions)
    ...
    but other than that my code is pretty much identical to yours. Any help would be greatly appreciated!

    • @jamesrobert5332
      @jamesrobert5332 Год назад

      I believe the import should come from next-auth/next, so it should be: import { getServerSession } from "next-auth/next";

    • @shattereddnb3268
      @shattereddnb3268 Год назад +1

      @@jamesrobert5332 I got it to work, I think what I did different was to give getServerSideProps context as an argument, and then context.req and context.res on getServerSession

  • @DanielTruongDev
    @DanielTruongDev Год назад

    does the API restriction prevent user from making request using HTTPS client like Postman?

    • @SamMeechWard
      @SamMeechWard  Год назад

      If the route is protected using next auth, then other clients will need a valid next auth cookie to use those routes.

  • @dundasbrands
    @dundasbrands Год назад

    ha me as well "copilot do the work for me"

  • @aprilm2941
    @aprilm2941 Год назад

    👀