# next-jotai-sync-location

> Sync jotai atoms with Nextjs router.

Latest version **0.1.3** (published 2022-06-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install next-jotai-sync-location
pnpm add next-jotai-sync-location
yarn add next-jotai-sync-location
bun add next-jotai-sync-location
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2022-06-28 |
| First published | 2022-06-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | adjsky |
| Maintainers | adjsky |
| Keywords | nextjs, jotai, location, sync |

## Links

- npm: https://www.npmjs.com/package/next-jotai-sync-location
- Repository: https://github.com/adjsky/next-jotai-sync-location
- Homepage: https://github.com/adjsky/next-jotai-sync-location#readme
- Issues: https://github.com/adjsky/next-jotai-sync-location/issues
- npm.io page: https://npm.io/package/next-jotai-sync-location

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 0.1.3 (latest) — 2022-06-28
- 0.1.2 — 2022-06-27
- 0.1.1 — 2022-06-27
- 0.1.0 — 2022-06-27
- 0.0.5 — 2022-06-27
- 0.0.4 — 2022-06-27
- 0.0.3 — 2022-06-27
- 0.0.2 — 2022-06-27
- 0.0.1 — 2022-06-27

## README

# Sync [jotai](https://jotai.org/) atoms with [Next.js](https://nextjs.org/) router

## Why?

As dai-shi [mentioned](https://github.com/pmndrs/jotai/issues/1140#issuecomment-1118084148), 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](https://jotai.org/docs/utils/atom-with-storage).

## Install

```bash
yarn add next-jotai-sync-location
```

or

```bash
npm install next-jotai-sync-location
```

## How to use

Method has the same signature as [atomWithHash](https://jotai.org/docs/utils/atom-with-hash), but you can't provide a subscription callback.

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

---
_Source: https://npm.io/package/next-jotai-sync-location · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
