Nasaq
Components

ConnectedAccounts

OAuth sign-in methods for an account, each provider with its official logo, the connected email or username, and Connect or Disconnect, and the last remaining sign-in method cannot be disconnected.

PreviewOpen ↗

Code

import { ConnectedAccounts, type ConnectedProvider } from "@fadymondy/nasaq/web";declare const providers: ConnectedProvider[];declare const api: { connect(id: string): Promise<void>; disconnect(id: string): Promise<void> };export function Accounts() {  return (    <ConnectedAccounts      providers={providers}      otherSignInMethods={1} // the password      onConnect={api.connect}      onDisconnect={api.disconnect}    />  );}

Integrations · beta

Live examples and controls: ConnectedAccounts in the lab.

Install

npx shadcn@latest add https://docs.nasaqui.com/r/connected-accounts.json

The social accounts linked to a sign-in. It lists each provider, shows the email or username that is connected, and offers Connect or Disconnect. Your callbacks start the OAuth flow and remove the link.

When to use

  • The security page of an account.

When not to use

Import

import { ConnectedAccounts } from "@fadymondy/nasaq/web";
// inside this monorepo: "@nasaq/web"

Quick start

import { ConnectedAccounts, type ConnectedProvider } from "@fadymondy/nasaq/web";

declare const providers: ConnectedProvider[];
declare const api: { connect(id: string): Promise<void>; disconnect(id: string): Promise<void> };

export function Accounts() {
  return (
    <ConnectedAccounts
      providers={providers}
      otherSignInMethods={1} // the password
      onConnect={api.connect}
      onDisconnect={api.disconnect}
    />
  );
}

Anatomy

ConnectedAccounts                  data-slot="connected-accounts"
└─ ul  aria-label
   └─ li                           data-slot="connected-account", data-provider, data-connected
      ├─ official logo
      ├─ name, and the account (left-to-right) or "Not connected"
      ├─ the "last method" explanation (when it applies)
      └─ Connect  |  Disconnect (ConfirmButton)  |  Disconnect disabled with a Tooltip

API

ConnectedAccounts: every div prop except children, plus:

PropTypeDefaultDescription
providersreadonly ConnectedProvider[]requiredThe rows, in order.
onConnect(id) => Promise<void>requiredStart OAuth. A throw shows an error.
onDisconnect(id) => Promise<void | { error? }>requiredRemove the link, after the confirm dialog.
otherSignInMethodsnumber0Ways to sign in that are not in this list: a password counts 1, each passkey 1.
labelsPartial<ConnectedAccountsLabels>Override any string.

ConnectedProvider: { id, connected, account?, name?, icon? }. The ids google, github, apple and microsoft use the official logos from OAuthButtons. For any other id pass name and the provider's own official logo as icon. Nasaq does not draw provider logos and you should not redraw, recolour or replace them with a generic icon.

The last-method rule: when connected accounts plus otherSignInMethods is 1 or less, the Disconnect button on the remaining account is disabled, a tooltip explains why and so does a visible line (tooltips do not show on touch). Enforce the same rule on the server.

Examples

A custom provider

import { ConnectedAccounts } from "@fadymondy/nasaq/web";

declare const OktaLogo: () => JSX.Element; // the official Okta mark, from Okta's brand kit

export function Accounts() {
  return (
    <ConnectedAccounts
      providers={[{ id: "okta", name: "Okta", icon: <OktaLogo />, connected: false }]}
      onConnect={async () => {}}
      onDisconnect={async () => {}}
    />
  );
}

Accessibility

  • The list is a labelled ul. Each button includes the provider name for screen readers ("Disconnect GitHub").
  • The disabled Disconnect stays focusable and is described by the visible explanation, so keyboard and screen reader users get the reason.
  • Disconnect uses AlertDialog. Logos are decorative (aria-hidden); the name is text.

RTL & i18n

  • English and Arabic strings follow the Nasaq locale. The connected email or username is left-to-right in Arabic.
  • Logos are never mirrored.

Styling & tokens

  • Card, Button, Status and --nq-* tokens. GitHub and Apple logos switch black or white with the theme. Target [data-slot="connected-account"][data-connected].

Do / Don't

  • Do enforce the last-method rule on the server as well.
  • Do pass otherSignInMethods honestly: count the password only if the account has one.
  • Don't substitute a generic icon for a missing logo.

Lab

https://docs.nasaqui.com/?path=/docs/components-integrations-connected-accounts--docs

On this page