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

Better Auth · Module

listAccounts

listAccounts retrieves every authentication method linked to the current user. Retain each returned account's id for unlinking or other account-specific operations.

How it works

Call authClient.listAccounts() to retrieve all authentication methods linked to the current user. The returned account records include an id that can be retained for account-specific operations such as unlinking or selecting an OAuth account.

Syntax

authClient.listAccounts()

Returns

A client response containing the current user's linked account records in data, or an error when the request fails.

Key points

  • The method lists all authentication methods associated with the signed-in user.
  • Each linked sign-in method is represented as an account record.
  • Preserve each returned account ID for later account-level actions.
  • Unlinking uses the Better Auth account record ID rather than only the provider name.

Common mistakes

  • Store the account record's id; a provider name alone is not the identifier needed for account-specific operations.

Example: List the current user's linked accounts

import { createAuthClient } from "better-auth/client";

const authClient = createAuthClient();

const { data: accounts, error } = await authClient.listAccounts();
if (error) {
  throw new Error(error.message);
}

for (const account of accounts ?? []) {
  console.log(account.id, account.providerId);
}

Creates a client, retrieves the signed-in user's linked authentication accounts, handles an error, and prints each account's identifier and provider.

When to use it

Show linked sign-in methods

Account management UI

Identify an account before unlinking

Account removal

Choose a specific provider account for token operations

OAuth account selection

Interview questions

QWhat does listAccounts return?

It retrieves every authentication method linked to the currently authenticated user. The result is returned through the client response as data, alongside a possible error.

Follow-up: How would you select a Google account? Find the returned record whose providerId is google, then pass its id as accountId to the account-specific API.

QHow should you handle the result safely?

Use const { data: accounts, error } = await authClient.listAccounts(). Check error before consuming accounts, because the client response can represent a failed request.

Follow-up: How should an application handle no linked accounts? Treat a missing or empty data collection as having no accounts and render the appropriate linking action.

QWhy should the returned account ID be preserved?

The account record's id is the durable selector for later account operations, including unlinking. providerId identifies the provider but is not the account record identifier.

Follow-up: Why can providerId be insufficient? A user may have account-specific records and APIs require the Better Auth account id to select one precisely.

  • Account Unlinking
  • getAccessToken
  • providerId
  • accountId

Source: User & Accounts. Checked 2026-10-15.