Not yet released. The packages on this page are not published to npm yet, so the install commands below will not resolve. The documented interface is stable and the code exists; only publication is outstanding. To use KeyStone from a frontend today, call the REST API or the TypeScript SDK, which is published. Contact us if you need early access.
The published SDKs and React package are pre-release (
0.1.x) and currently lag the live API - some field names below may not match the API yet. When wiring against the API directly, prefer the REST examples in the API reference. The hook snippets show the intended shape and return when the packages catch up.Import
import { useTemplates } from '@keystoneos/react';
Usage
function TemplateSelector({ onSelect }) {
const { templates, isLoading } = useTemplates();
if (isLoading) return <Spinner />;
return (
<select onChange={e => onSelect(e.target.value)}>
{templates.map(t => (
<option key={t.id} value={t.slug}>
{t.name} - Roles: {t.config.required_roles.join(', ')}
</option>
))}
</select>
);
}
Parameters
None.Return Type
interface UseTemplatesResult {
templates: SettlementTemplate[];
isLoading: boolean;
error: string | null;
refetch: () => Promise<void>;
}
| Property | Type | Description |
|---|---|---|
templates | SettlementTemplate[] | Array of available templates. |
isLoading | boolean | true during fetch. |
error | string | null | Error message if fetch failed. |
refetch | () => Promise<void> | Manually re-fetch templates. |
SettlementTemplate
| Property | Type | Description |
|---|---|---|
id | string | Template UUID. |
slug | string | URL-friendly identifier (e.g., "dvp-standard"). |
name | string | Human-readable name. |
description | string | Template description. |
config | TemplateConfig | Template parameter pack. |
TemplateConfig
| Property | Type | Description |
|---|---|---|
machine | string | State machine this template runs (e.g. "dvp/v1"). Fixed in code, selected here. |
timeout_seconds | number | Settlement timeout in seconds (minimum 60, default 3600). |
compliance | ComplianceConfig | Compliance provider configuration. |
required_roles | string[] | Party roles needed (e.g., ["seller", "buyer"]). |
actions | object | Per-state action handlers, keyed by engine-owned state name. |
Behavior
- Fetches once on mount.
- Templates are global (not environment-scoped) and rarely change.
- Use
refetch()if you need to re-check after template updates.