deleteSocialConnection()
Removes one social identity connection from the target user.
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 unlinkSocial(userId: string, connectionId: string) { const client = await wachtClient(); await client.users.deleteSocialConnection(userId, connectionId);}Signature
function deleteSocialConnection( userId: string, connectionId: string,): Promise<void>Parameters
›userId: string;
userId: string;Target user id that owns the social connection.
›connectionId: string;
connectionId: string;Social connection id to unlink from the user.
Behavior
- Performs a destructive operation against the target resource.
- Callers should treat this as irreversible unless a separate restore flow exists.
Examples
Unlink after validating owner user
import { wachtClient } from '@wacht/nextjs/server';export async function unlinkGithubConnection(userId: string, connectionId: string) { const client = await wachtClient(); const user = await client.users.getUser(userId); const hasConnection = (user.social_connections ?? []).some((connection) => connection.id === connectionId); if (!hasConnection) { throw new Error('Connection does not belong to this user'); } await client.users.deleteSocialConnection(userId, connectionId);}