SmithersProvider
The<SmithersProvider> component provides unified context to all child components, including database access, execution state, task orchestration, global timeouts, and stop conditions. Itβs required at the root of every Smithers workflow.
SmithersProvider includes the Ralph loop internally. The <Ralph> component is deprecated, but its loop props (maxIterations, onIteration, onComplete) are supported here and documented below.
Basic Usage
Props
The database instance for state persistence.
Unique identifier for the current execution.
Optional configuration for the workflow.
Maximum number of iteration loops before stopping.
Called at the start of each iteration. Useful for logging or progress tracking.
Called when orchestration completes (all tasks finished or max iterations reached).
Maximum time in milliseconds for the entire workflow.
Array of conditions that can stop the workflow early.
Create a VCS snapshot before starting (useful for rollback).
Called when workflow encounters an error.
Called when a stop is requested (via stop condition or manual request).
Close the database when workflow completes.
Context Values
Child components can access the context using theuseSmithers hook:
Task Tracking
Components can register and complete tasks using the database-backed task system:Request Stop
Stop the workflow programmatically:Accessing the Database
Access the database directly from any child component:Reactive Queries
Use reactive database queries with theuseQuery hook:
Complete Example
Best Practices
Always wrap with SmithersProvider
Always wrap with SmithersProvider
All Smithers components require the provider:
Set maxIterations to prevent runaway loops
Set maxIterations to prevent runaway loops
Always set a reasonable iteration limit:
Use db.tasks for task tracking
Use db.tasks for task tracking
Register async work with the database for proper orchestration:
Close the database when done
Close the database when done
Ensure writes are flushed: