# dom-state

> Simple tool to manage JS state with data-attributes

Latest version **1.0.2** (published 2024-01-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install dom-state
pnpm add dom-state
yarn add dom-state
bun add dom-state
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-01-14 |
| First published | 2024-01-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | GGsmou |
| Maintainers | ggsmou |
| Keywords | state |

## Links

- npm: https://www.npmjs.com/package/dom-state
- Repository: https://github.com/GGsmou/DOM-state
- Homepage: https://github.com/GGsmou/DOM-state#readme
- Issues: https://github.com/GGsmou/DOM-state/issues
- npm.io page: https://npm.io/package/dom-state

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2024-01-14
- 1.0.1 — 2024-01-05
- 1.0.0 — 2024-01-05

## README

# DOM-state

Simple library for managing state with a `data-attributes`.

```bash
npm install dom-state
```

## How to use

```ts
import { useDomState } from 'dom-state';

const [getState, setState] = useDomState(element, 0);

button.addEventListener('click', () => {
  setState(
    (prev) => prev + 1, // or direct value
    (newState) => `counter: ${newState}`,
  );
});
```

For more details check [source code](https://github.com/GGsmou/DOM-state/blob/main/src/index.ts)

## How to contribute

If you want to add something, or fix a bug create an issue/PR [here](https://github.com/GGsmou/DOM-state), I make sure to check it out.

## PS

This is fun project, inspired by [article](https://guseyn.com/html/posts/templates-instead-of-reactivity.html), so use in production at your own risk :)

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