authenticationsessionnext.jsnext-auth

How I can update session in server side


How I can update session in server side using authV5 in nextjs latest update

I tried :

import { update } from "@/auth

But the update not in auth


Solution

  • In authV5, you need to import the update method when you create your NextAuth instance:

    auth.ts:

    export const { auth, signIn, signOut, update } = NextAuth({ ... })
    

    You can then import it into another component as you are doing:

    import {update} from "@/auth"