@exaflow/react
v0.4.0
Published
React components and hooks for exaflow
Downloads
14
Maintainers
Readme
@exaflow/react
Headless React hooks for exaflow (works in React and React Native).
Install
pnpm add @exaflow/react @exaflow/coreUsage
import { useFlowEngine, type XFFlow } from '@exaflow/react';
export function FlowRunner({ flow }: { flow: XFFlow }) {
const { currentNode, choices, isComplete, makeChoice, reset } =
useFlowEngine(flow);
if (isComplete) return <button onClick={reset}>Restart</button>;
return (
<div>
<h2>{currentNode?.title}</h2>
<p>{currentNode?.content}</p>
<div>
{choices.map((c) => (
<button key={c.id} onClick={() => makeChoice(c.id)}>
{c.label}
</button>
))}
</div>
</div>
);
}