manages browsing session history jsr.io/@mary/history
typescript jsr
TypeScript 100.0%
13 1 0

Clone this repository

https://tangled.org/mary.my.id/pkg-history
git@tangled.org:mary.my.id/pkg-history

For self-hosted knots, clone URLs may differ based on your setup.

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