As dai-shi mentioned, there is no easy way to keep atoms in sync with window.location or the various available routers, so i wrote a simple wrapper over atomWithStorage.
yarn add next-jotai-sync-location
or
npm install next-jotai-sync-location
Method has the same signature as atomWithHash, but you can't provide a subscription callback.
import atomWithLocation from "next-jotai-sync-location"
const countAtom = atomWithLocation("count", 0)
const countAtomWithReplace = atomWithLocation("count", 0, {
replaceState: true
})
const countAtomWithoutDelay = atomWithLocation("count", 0, { delayInit: false })