NewWacht Bench is live — AI-assisted development for Wacht

deleteUser()

client.users.deleteUser(userId) permanently removes a user through the backend management API.

Usage

The following example shows a basic usage of the backend client from @wacht/nextjs/server.

import { wachtClient } from '@wacht/nextjs/server';export async function deleteUser(userId: string) {  const client = await wachtClient();  await client.users.deleteUser(userId);}

Signature

function deleteUser(  userId: string,): Promise<void>

Parameters

userId?: string | undefined;
Stable id of the user to delete.

When to use it

Use deleteUser() for administrative cleanup and hard-delete flows where the user record should no longer exist.
If you only need to stop access temporarily, updateUser() with disabled: true is usually the safer option.

Return value

This method does not return a user object. A successful call resolves with no value.

Examples

Delete a user

import { wachtClient } from '@wacht/nextjs/server';export async function deleteUser(userId: string) {  const client = await wachtClient();  await client.users.deleteUser(userId);}

Delete after a final lookup

import { wachtClient } from '@wacht/nextjs/server';export async function deleteDisabledUser(userId: string) {  const client = await wachtClient();  const user = await client.users.getUser(userId);  if (!user.disabled) {    throw new Error('Refusing to delete an active user');  }  await client.users.deleteUser(userId);}

On this page