Function updateSession

  • Update the session object. The provided session object will replace the existing session.

    Note you can't use this method to login or logout - you should use the login and logout handlers for this. If no session is provided, it doesn't contain a user or the user is not authenticated; this is a no-op.

    // pages/api/update-user.js
    import { getSession, updateSession } from '@auth0/nextjs-auth0';

    export default async function updateSession(req, res) {
    if (req.method === 'PUT') {
    const session = await getSession(req, res);
    updateSession(req, res, { ...session, user: { ...session.user, foo: } });
    res.json({ success: true });


    • Rest ...args: [IncomingMessage, ServerResponse<IncomingMessage>, default] | [NextApiRequest, NextApiResponse<any>, default] | [NextRequest, NextResponse<unknown>, default] | [default]

    Returns Promise<void>