Distributed state without the infrastructure overhead
Share state across workflows, plugins, and services with zero external dependencies.
How it fits together
Workflow
State Broker
Plugin
Redis (optional)
Why not just use Redis directly?
| Feature | Traditional | State Broker |
|---|---|---|
| External dependencies | Redis, Memcached, etc. | None required |
| Setup time | Hours of configuration | Zero — works out of the box |
| Scaling path | Re-architect from scratch | Swap backend, same API |
| Tenant isolation | Build it yourself | Built-in with quotas |
Cache API
import { useCache } from '@kb-labs/sdk';
const cache = useCache();
// Store with TTL
await cache.set('user:123', data, 60_000);
// Retrieve
const user = await cache.get('user:123');Pub/Sub
import { useBroker } from '@kb-labs/sdk';
const broker = useBroker();
// Subscribe to changes
broker.subscribe('deploy:*', (event) => {
console.log(event.key, event.value);
});
// Publish
broker.publish('deploy:started', { env: 'prod' });Scaling path
Development
In-Memory
~1msFast in-process cache for local development and small teams. No infrastructure required.
Production
Redis
~5msShared state across instances with persistence. Same API — swap the backend config.
Enterprise
Multi-Region
distributedGeo-replicated state with per-region routing. Dedicated backends per tenant.
Simplify your state management
No more external dependencies for shared state.