Advanced
•1 min read
Advanced Features
Advanced features for production Directive applications – composition patterns, debugging tools, server rendering, and fault tolerance.
Features
| Feature | Page | When to Use |
|---|---|---|
| Multi-Module | Compose multiple modules into one system | Apps with distinct domains (auth, cart, UI) |
| Time-Travel | Step through state history, undo/redo | Debugging complex state transitions |
| Snapshots | Serialize, restore, and distribute system state | Persistence, sharing, migration |
| SSR & Hydration | Server-render Directive state, hydrate on client | Next.js, Remix, SvelteKit |
| Error Handling | Error boundaries, retry policies, circuit breakers | Production resilience |
Multi-Module Composition
Combine modules with namespaced access:
import { createSystem } from '@directive-run/core';
// Compose multiple modules into a single system
const system = createSystem({
modules: { auth: authModule, cart: cartModule },
});
// Each module's facts live under its namespace
system.facts.auth.user;
system.facts.cart.items;
Time-Travel Debugging
Enable snapshots and navigate state history:
// Enable time-travel with a snapshot history limit
const system = createSystem({
module: myModule,
debug: { timeTravel: true, maxSnapshots: 100 },
});
// Navigate backward and forward through state history
system.debug.goBack(); // Undo
system.debug.goForward(); // Redo
Next Steps
- Building a large app? Start with Multi-Module
- Debugging issues? See Time-Travel
- Going to production? See Error Handling

