Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Auth.js · Enum

updateUser

updateUser is an optional Auth.js adapter method for persisting changes to an existing user. It receives partial user data with a required id and returns the updated AdapterUser.

How it works

updateUser is an optional adapter method. Auth.js passes a partial user object that always includes the user’s id; the adapter applies those changes in its database and returns the complete updated AdapterUser.

Syntax

optional updateUser(user): Awaitable<AdapterUser>

Parameters

NameTypeDescription
userPartial<AdapterUser> & Pick<AdapterUser, "id">A partial user update whose id property is required for locating the database record.

Returns

Awaitable<AdapterUser>

Key points

  • updateUser is optional on the adapter interface and may resolve synchronously or asynchronously to an AdapterUser.
  • Its responsibility is to persist user changes and return the resulting user object.
  • The input permits a subset of user fields while requiring the user identifier.
  • This method belongs to the adapter’s persistence operations rather than to a provider callback.

Common mistakes

  • The input is partial, but id is required; use it to select the record rather than assuming every user field is present.

Example: Implement an adapter user update

import type { Adapter, AdapterUser } from "next-auth/adapters"

export const adapter: Adapter = {
  async updateUser(user) {
    const updated: AdapterUser = await db.user.update({
      where: { id: user.id },
      data: user,
    })
    return updated
  },
}

Implements the adapter method by updating the persisted user identified by id and returning the resulting adapter user.

When to use it

Persist changed profile fields while retaining the existing user identifier.

Profile editing

Implement the update operation required by a database-backed Auth.js adapter.

Account lifecycle management

Interview questions

QWhat does updateUser do, and what does it return?

updateUser is an optional adapter method that updates a user in the database and returns the updated AdapterUser. Its argument is a partial adapter user combined with a required id.

Follow-up: What must an implementation do if only name is supplied? It should update only the supplied field for the user selected by id, then return the complete persisted user.

QWhat is the parameter type for updateUser?

The method receives Partial<AdapterUser> & Pick<AdapterUser, "id">. Therefore, callers may omit mutable user properties, but the identifier is always available for locating the record.

Follow-up: Why should the implementation avoid replacing the whole row? Because omitted properties are valid in the partial input and should not be overwritten accidentally.

QHow is updateUser connected to Auth.js configuration?

An adapter is passed to Auth.js through the adapter configuration option. The adapter methods provide persistence operations, including updating users.

Follow-up: How does this relate to the adapter contract? The implementation must conform to the Adapter interface and return an AdapterUser after persistence succeeds.

  • Adapter
  • AdapterUser
  • createUser
  • getUser
  • deleteUser
  • User management

Source: Adapters. Checked 2026-10-15.