Travels: Fast framework-agnostic undo/redo powered by mutative JSON patch
13 days ago
- #javascript
- #undo-redo
- #state-management
- Travels is a fast, framework-agnostic undo/redo library that stores only changes (JSON Patches) instead of full snapshots, making it 10x faster and more memory-efficient.
- It works with React, Vue, Zustand, or vanilla JavaScript and is ideal for text editors, drawing apps, form builders, and interactive applications.
- Key advantages include memory-efficient history storage (only differences are stored) and fast immutable updates built on Mutative.
- Travels supports both auto archive mode (each setState creates a history entry) and manual archive mode (group multiple changes into one undo/redo step).
- The library provides comprehensive API methods like setState, back, forward, go, reset, and subscribe for managing state history.
- State must be JSON-serializable; complex types like Date, class instances, and functions are not supported.
- Travels offers TypeScript support and can be extended with custom logic for validation, permissions, logging, and more.
- Integration examples are provided for React, Vue, and Zustand, along with persistence options for saving history to storage.