Skip to content

Time Travel

Simple and lightweight undo/redo for JavaScript and TypeScript.
Terminal window
npm install @biswaviraj/time-travel
# or
pnpm add @biswaviraj/time-travel
import { timeTravel } from "@biswaviraj/time-travel";
const tt = timeTravel<number>(0);
tt.add(1);
tt.add(2);
tt.add(3);
tt.get(); // 3
tt.undo(); // returns 2
tt.undo(); // returns 1
tt.redo(); // returns 2
tt.canUndo; // true
tt.canRedo; // true

Undo / Redo

Step back and forward through state with return values.

History Navigation

Jump N steps with go(n) or inspect the full history.

React Hook

useTimeTravel for reactive undo/redo in React components.

Zero Dependencies

Fully typed, tree-shakeable, and under 1kB gzipped.