manages browsing session history jsr.io/@mary/history
typescript jsr
TypeScript 100%

README.md

history #

JSR | source code

manages browsing session history

import { createBrowserHistory } from '@mary/history';
import { createHistoryStack } from '@mary/history/stack';

const history = createBrowserHistory();
const stack = createHistoryStack(history);

history.listen(({ action, location }) => {
	console.log(action, location.pathname);
});

history.navigate('/dashboard?tab=stats#top');
// action: "push", location.pathname: "/dashboard"

history.update({ theme: 'dark' });
// action: "update"

console.log(stack.entries.map((e) => e?.pathname));
// e.g. ["/", "/dashboard"]

history.back();
// action: "traverse"

console.log(stack.canGoForward); // true