import create, { saveHistory } from "stalo/lib/persistent"; import { useEffect } from "react"; import { useHashLocation } from "wouter/use-hash-location"; const [useCount, setCount, setCountByStorage] = create(0); export default function CounterPersistent() { // Update the count when the location changes. const [location] = useHashLocation(); useEffect(setCountByStorage, [location]); return ( <>

The count is stored in the url, it will persist after you refresh the page, you can use the back and forward buttons to navigate the history:

); } function Display() { const count = useCount(); return

{count}

; }