PATCH-BASED STATE HISTORY
Every change.A way back.
Durable undo/redo for modern applications. Keep compact history, write natural mutation-style updates, and integrate with the state tools you already use.
pnpm add travels mutativeWorks with React · Vue · Zustand · MobX · Pinia · Vanilla JS
replace /title "Launch board"WHY TRAVELS
A smaller history. A bigger editing experience.
Built for large state, small updates, long timelines, and histories that need to survive a reload—not just the current render.
Patch-based by design
Record forward and inverse JSON Patches instead of copying the whole state for every edit.
ExploreHistory worth keeping
Serialize state, patches, cursor, and metadata into one versioned, restorable snapshot.
ExploreYour framework, your store
Use immutable timelines or preserve reactive references with mutable mode and journals.
ExplorePredictable at the edges
Atomic transactions, typed errors, semantic restore validation, and explicit compatibility.
ExploreTRY IT LIVE
Build it up. Take it back.
Every block below is a real Travels update, and a whole drag stroke is archived as one undoable step. Inspect the patches, scrub the timeline, then reload the page: the history is restored from this browser’s storage.
Click or drag across the board. One drag is archived as one undo step. Keyboard: arrows move, Enter applies, Delete erases, B/P/E switch tools, 1–6 pick a color, R rotates.
patches[0] forward · redo replays these
The starting scene has no incoming patch. Place a block to record one.
inversePatches[0] inverse · undo applies these
Nothing to undo from here.
Each step adds the whole scene to a snapshot stack, but only the change to Travels.
JSON.stringify(travels.serialize()) versus every state in getHistory(). Snapshots can win while a scene is tiny; small edits to larger state widen the gap.
NATURAL UPDATES, PRECISE HISTORY
Write like it’s mutable.
Travel like it’s immutable.
Travels uses Mutative to turn familiar draft mutations into immutable state and reversible patches. No reducer boilerplate, no manual inverse operations.
- No-op updates stay out of history
- Metadata labels every meaningful edit
- Read-only controls fit any UI
import { createTravels } from 'travels';const travels = createTravels({ document: { title: 'Untitled' }});travels.setState((draft) => { draft.document.title = 'Hello, Travels';});travels.back(); // undotravels.forward(); // redo- getState()
- { document: { title: 'Hello, Travels' } }
- getPosition()
- 1
- canBack() / canForward()
- true / false
- applied patch
- replace /document/title "Hello, Travels"
ONE CORE, TWO OWNERSHIP MODELS
History that fits your architecture.
Let Travels own updates, or keep your existing store authoritative. The history contract stays explicit in both directions.
createTravels()
Send updates through Travels and receive immutable states, patches, navigation, and controls.
Updates flow from your code through Travels to your UI. back() and forward() go from your UI to Travels.
createTravelJournal()
Record patches from an existing store or state machine, then delegate undo/redo through its commit path.
Your store commits and records patches in the journal, which drives your UI. back() and forward() are delegated back through your store’s commit path.
MADE FOR MEANINGFUL EDITS
Give every interaction a way back.
From a single field to a complex canvas, make exploration feel safe.
Visual editors
Group complex canvas operations into atomic steps and keep long editing sessions compact.
Canvas · Design tools · WhiteboardsForms & builders
Choose when edits become undoable steps with manual archives and external form ownership.
Forms · Page builders · WorkflowsLocal-first apps
Persist complete timelines, validate restored history, and recover intentionally from bad data.
Offline drafts · IndexedDB · SyncDOCUMENTATION FOR THE WHOLE JOURNEY
Start small. Understand every edge.
Practical guides, integration recipes, operational guardrails, and source-generated API reference.
Build your first timeline
Install Travels, record an edit, and connect undo/redo controls in minutes.
Read the guide GO DEEPERDesign the right history
Learn archive modes, transactions, branching, mutable state, and external journals.
Read the guide SHIP WITH CONFIDENCEPersist and restore safely
Add durable storage, migrations, corruption recovery, and integrity boundaries.
Read the guideMAKE YOUR NEXT EDIT REVERSIBLE
Your users make mistakes.
Your state doesn’t have to.
One small package. A complete history engine.