next-jotai-sync-location
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

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 })

Package Sidebar

Install

npm i next-jotai-sync-location

Weekly Downloads

2

Version

0.1.3

License

MIT

Unpacked Size

8.94 kB

Total Files

7

Last publish

Collaborators

  • adjsky