@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.
| Prop | Type | Required | Description |
|---|---|---|---|
client | StewardClient | ✅ | Configured SDK client |
agentId | string | ✅ | Agent ID to scope all components to |
theme | ThemeOverrides | — | Override default CSS custom properties |
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.
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.
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.
<SpendDashboard>
Spend analytics for the agent with budget bars and summary numbers.
Authentication Components
<StewardLogin>
Drop-in auth widget supporting passkeys, email magic links, and OAuth providers.
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.
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:
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:
<StewardTenantPicker>
Switch between connected apps/tenants:
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:
@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
hiddenorenforcedinpolicyExposure - Apply the tenant’s theme as base styles
- Show/hide features based on
featureFlags(e.g.,showFundingQR,showApprovalQueue) - Use policy templates from
policyTemplatesin the policy editor
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 >= 18react-dom >= 18@stwd/sdk >= 0.3.0
Related
- SDK Client Reference — The underlying
StewardClientAPI - Tenant Config — Control plane for per-tenant theming + feature flags
- Approvals API — REST API for the approval workflow