0.1.3 • Published 3 years ago
next-jotai-sync-location v0.1.3
Sync jotai atoms with Next.js router
Why?
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.
Install
yarn add next-jotai-sync-location
or
npm install next-jotai-sync-location
How to use
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 })