Skip to main content
Neon Postgres Docs
current

Search documentation

Type to search this documentation.

On this pageOverview

User management

Manage user profiles and account settings after users sign in. This guide covers Updating profile information (name, image, phone number) Changing passwords securely Changing email addresses with veri...

Manage user profiles and account settings after users sign in. This guide covers:

  • Updating profile information (name, image, phone number)
  • Changing passwords securely
  • Changing email addresses with verification
  • Deleting user accounts

Update user profile fields like name, image, or phone number using updateUser():

src/App.jsx
import { authClient } from './auth';

const handleUpdateProfile = async (e) => {
  e.preventDefault();
  setMessage('');

  try {
    const { data, error } = await authClient.updateUser({
      name: 'New Name',
    });

    if (error) throw error;

    // Refresh session to get updated user data
    const sessionResult = await authClient.getSession();
    if (sessionResult.data?.session) {
      setUser(sessionResult.data.session.user);
      setMessage('Profile updated successfully!');
    }
  } catch (error) {
    setMessage(error?.message || 'Update failed');
  }
};

You can update these fields with updateUser():

  • name (string) - User's display name

Change a user's password while they are logged in using changePassword(). This requires the current password for security:

src/App.jsx
import { authClient } from './auth';

const handleChangePassword = async (e) => {
  e.preventDefault();
  setMessage('');

  try {
    const { data, error } = await authClient.changePassword({
      newPassword: 'new-secure-password',
      currentPassword: 'current-password',
    });

    if (error) throw error;
    setMessage('Password changed successfully!');
  } catch (error) {
    setMessage(error?.message || 'Password change failed');
  }
};

Optionally sign out from all other devices when changing the password:

src/App.jsx
const { data, error } = await authClient.changePassword({
  newPassword: 'new-secure-password',
  currentPassword: 'current-password',
  revokeOtherSessions: true, // Signs out all other devices
});

After updating profile information, refresh the session to get the latest user data:

src/App.jsx
import { authClient } from './auth';

const refreshUser = async () => {
  const { data } = await authClient.getSession();
  if (data?.session) {
    setUser(data.session.user);
  }
};

Call refreshUser() after successful updateUser() calls to ensure your UI displays the latest information.

Join our Discord Server to ask questions or see what others are doing with Neon. For paid plan support options, see Support.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu