This project demonstrates using @stateflowx/client inside a React application with realtime workflow execution and runtime event streaming.
The demo connects to a local StateFlowX runtime host over WebSockets, initializes the runtime configuration, executes a workflow, and renders the response in the UI.
Runtime lifecycle events are also streamed in realtime from the runtime to the React client.
Before running this project, you must also run the runtime host example:
https://github.com/bws9000/stateflowx-runtime-host-example
Clone the runtime host example:
git clone https://github.com/bws9000/stateflowx-runtime-host-example.gitInstall dependencies:
npm installStart the runtime host:
node main.mjsThe runtime host should now be running locally on:
ws://localhost:3001Install dependencies:
npm installRun the React application:
npm run devOpen:
http://localhost:5173StateFlowX V1 currently standardizes on:
- JSON-RPC
- WebSocket transport
- realtime runtime event streaming
HTTP transport support exists internally, but realtime runtime events currently require WebSockets.
This demo demonstrates:
@stateflowx/client- runtime initialization
- realtime runtime event streaming
- JSON-RPC communication
- WebSocket transport
- workflow execution
- provider fallback configuration
- AI-driven response formatting
- React integration
- realtime orchestration connectivity
The React client currently logs runtime lifecycle events including:
workflow.startedworkflow.completedworkflow.failedruntime.message.received
These events are streamed from the runtime host over WebSockets.
React App
->
@stateflowx/client
->
WebSocket Transport
->
JSON-RPC Protocol
->
StateFlowX Runtime Host
->
Workflow Execution
->
Providers / Services
->
Runtime Events
->
Realtime Client Observabilityworkflow.started
->
service.execute
->
provider.generate
->
workflow.completed
->
React runtime event stream