6 min read
|
Saved February 14, 2026
|
Copied!
Do you care about this?
Travels is a lightweight library for implementing undo and redo functionality in applications. It only stores the differences between states, making it memory-efficient and faster than traditional systems. It works with various frameworks and is easy to integrate.
If you do, here's more
Travels is a fast, framework-agnostic library for implementing undo and redo functionality in applications. Unlike traditional systems that duplicate entire state objects with each change, Travels only records the differences between states using JSON Patches, significantly reducing memory usage and improving performance. For example, if your state is 1MB and a user makes 100 edits, traditional methods might consume 100MB of memory, while Travels could use just a few kilobytes. Built on the Mutative framework, it performs updates 10 times faster than Immer, allowing developers to write intuitive mutation code while maintaining immutability.
The library integrates easily with popular frameworks like React, Vue, and Zustand, and supports both mutable and immutable modes. With a straightforward installation process using npm, yarn, or pnpm, developers can quickly set up a Travels instance and start managing state changes. The API includes methods for subscribing to state changes, undoing and redoing actions, and controlling the history of state changes. You can also customize the maximum number of history entries to retain, helping manage memory efficiently.
Understanding key concepts like state, drafts, and patches is essential for using Travels effectively. State refers to the application data, drafts are temporary mutable copies, and patches are the changes between states. The library allows for various ways to update state, whether by direct assignment, replacing the entire state, or modifying a draft. It also features an auto-archiving option, enabling developers to save states manually or automatically, depending on their needs. Overall, Travels offers a powerful solution for managing state changes without the overhead of traditional undo systems.
Questions about this article
No questions yet.