Skip to content
DexterDocs
Dexter Connect / Account Access
Sections

Account Access

This React example signs someone in to your app with a passkey from the earlier Dexter Wallet. useDexterConnection opens the passkey prompt and verifies that the returned account and wallet belong together. DexterAccountControl displays the account panel.

Install

These versions of Connect and Vault support the earlier Wallet integration in React 18 or later. To build with the new on-chain Dexter Account, request beta access.

npm install @dexterai/connect@0.31.3 @dexterai/vault@0.44.1

On third-party origins, sign-in opens Dexter's hosted authorization window.

Add the Control

This React client component stores its session in memory. Reloading clears it; connect your application's session adapter for persistence.

DexterSignIn.tsx
'use client';

import { useCallback, useState } from 'react';
import type { PasskeyLoginTokens } from '@dexterai/connect';
import {
  DexterAccountControl,
  useDexterConnection,
  type DexterAccountSession,
} from '@dexterai/connect/react';

export function DexterSignIn() {
  const [accountSession, setAccountSession] = useState<DexterAccountSession>({
    status: 'signed_out',
  });

  const installAccountSession = useCallback((session: PasskeyLoginTokens) => {
    setAccountSession({ status: 'authenticated', accessToken: session.accessToken });
  }, []);
  const clearAccountSession = useCallback(() => {
    setAccountSession({ status: 'signed_out' });
  }, []);

  const dx = useDexterConnection({
    intent: 'identity',
    accountSession,
    installAccountSession,
    clearAccountSession,
  });
  return <DexterAccountControl connection={dx} />;
}

Render <DexterSignIn /> in your header. The SDK supplies the account mark, panel, balance reader and interaction states. For wallet operations, use intent: 'wallet' and gate your app's actions on the returned permissions.

Reuse one connection instance across your app. Pass navigation to replace hosted destinations with local routes, and items for app-specific links. The reference lists these options.

Connect Your Session Store

Replace the two callbacks with your app's authentication adapter:

  • installAccountSession(session) installs the returned session and updates accountSession with that same access token. Reject if installation fails.
  • Clear the host session inside clearAccountSession() and update the state to signed_out.
  • While restoring a stored session, pass { status: 'loading' }. Update it after restoration completes.

Keep tokens and wallet identity proofs out of logs and page markup. Gate account content on model.permissions.accountContentVisible; the SDK keeps it unavailable while verification runs or identities conflict. Your backend must also authenticate and authorize its own requests.

Check the Integration

Click the control, complete the Dexter passkey prompt, and return to the app. The connected identity should appear after verification. Cancel a prompt and confirm that no connected state appears. Disconnect and confirm that account content disappears.

See Connect Reference for result fields, the earlier Wallet creation flow, connection states, and styling.

Last Updated:

On this page