Skip to main content

@stwd/react

Drop-in React components for building agent management UIs. Includes wallet overview, transaction history, policy controls, approval queues, and spend analytics — all wired to the Steward API with zero configuration.

Install

Quick Start


Provider

<StewardProvider>

Wraps all other Steward components. Must be a parent of any component that uses Steward hooks or components.

Components

<WalletOverview>

Displays the agent’s wallet address, on-chain balance, chain info, and optionally a funding QR code.

<TransactionHistory>

Paginated transaction history with status badges and blockchain explorer links.
Displays: timestamp, destination address, value (ETH), status badge (signed / pending_approval / rejected / failed), and a link to the block explorer.

<PolicyControls>

Human-friendly policy management UI. Shows the current policy set with toggles, limits, and address lists.
Supports all policy types: spending-limit, approved-addresses, rate-limit, time-window, auto-approve-threshold. Respects the tenant’s policyExposure config — policies marked hidden or enforced are not shown.

<ApprovalQueue>

Shows pending transactions awaiting human review. Supports approve and deny actions.
Each item shows the destination address, value, requesting agent, and time waiting. Approve/deny actions call the API immediately.

<SpendDashboard>

Spend analytics for the agent with budget bars and summary numbers.
Shows: total spent in the selected range vs. the policy limit, daily breakdown chart, and largest single transactions.

Authentication Components

<StewardLogin>

Drop-in auth widget supporting passkeys, email magic links, and OAuth providers.
The component auto-discovers enabled providers via GET /auth/providers and only shows buttons for methods that are enabled on both the server and in the props.

<StewardMfaChallenge>

Custom MFA verification UI for login or sensitive wallet-action challenges. It supports TOTP, SMS, recovery-code fallback for TOTP, and passkey step-up.

<StewardMfaSettings>

User-facing MFA management for enrollment status, TOTP setup, SMS setup, and unenrollment flows.

<StewardUserWalletKeyImport>

Hosted encrypted private-key import for an authenticated user’s embedded wallet. The component initializes a one-time import session, encrypts the supplied EVM or Solana key in the browser with WebCrypto, submits only the encrypted envelope, and clears the local input after a successful import.
Use it only inside StewardProvider with a user bearer session that can satisfy the tenant’s recent-MFA policy for keyImport. The server still enforces import feature flags, tenant policy, session binding, replay rejection, and no-store responses.

<StewardEmailCallback>

Mount on your /auth/callback route to handle magic link token verification:
Reads token and email from URL search params automatically.

<StewardAuthGuard>

Renders children only when the user is authenticated. Shows a login form (or custom fallback) when not authenticated.

<StewardUserButton>

User avatar and dropdown menu with sign-out and optional tenant switching:
Displays the user’s email or truncated wallet address. Gravatar integration for email users.

<StewardTenantPicker>

Switch between connected apps/tenants:
Shows tenant memberships with roles. Handles switching via auth.switchTenant() internally.

Hooks

All components are built on public hooks — use them directly for custom UIs.

useSteward()

Access the Steward context: client, agentId, theme, and tenant config.

useWallet()

Agent identity and on-chain balance with auto-refresh.

useTransactions(opts?)

Paginated transaction history.

usePolicies()

Current policy set with CRUD operations.

useApprovals(interval?)

Pending approvals with approve/reject actions.

useSpend(range?)

Spend analytics for a time range.

useAuth()

Access the auth context for custom auth UIs.

Theming

Components use CSS custom properties scoped to .stwd-root. Override any --stwd-* variable in your stylesheet:
Or pass overrides to the provider:
The tenant’s control plane config can also supply a theme — @stwd/react fetches it automatically from GET /tenants/:id/config and merges it with any prop overrides. Hosted asset URLs are carried in the merged theme object for embedded components that render tenant branding; the API only persists absolute HTTPS URLs, with localhost HTTP allowed for development.

Tenant Control Plane Integration

If your Steward tenant has a control plane config configured, @stwd/react will automatically:
  • Hide or lock policies marked as hidden or enforced in policyExposure
  • Apply the tenant’s theme as base styles
  • Show/hide features based on featureFlags (e.g., showFundingQR, showApprovalQueue)
  • Use policy templates from policyTemplates in the policy editor
This lets platform operators white-label the UI and control what end users can configure.

Full Example


Known Limitations

  • Components require a configured StewardClient; they do not create tenants or platform keys.
  • Control-plane theming and feature flags depend on the tenant config API being reachable.
  • Approval and transaction components poll the API; choose intervals appropriate for your deployment.

Peer Dependencies

  • react >= 18
  • react-dom >= 18
  • @stwd/sdk >= 0.3.0