Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kusstar/signals-persist

A library for persisting state of a [signal](https://github.com/preactjs/signals).
https://github.com/kusstar/signals-persist

persist preact react signals state-management storage

Last synced: 7 days ago
JSON representation

A library for persisting state of a [signal](https://github.com/preactjs/signals).

Awesome Lists containing this project

README

        

# signals-persist

A library for persisting state of a [signal](https://github.com/preactjs/signals).

## Installation

```bash
npm install signals-persist
yarn add signals-persist
pnpm add signals-persist
```

## Usage

### React

Install the `@preact/signals-react` package.

```bash
npm i @preact/signals-react
yarn add @preact/signals-react
pnpm add @preact/signals-react
```

```jsx
import { signal } from '@preact/signals-react'

import { persist } from 'signals-persist'

const count = persist(signal(0), 'count')

const App = () => {
return (


{count.value}

count.value++}
>
count++


)
}

export default App;
```

### Preact

Install the `@preact/signals` package.

```bash
npm i @preact/signals
yarn add @preact/signals
pnpm add @preact/signals
```

```jsx
import { signal } from '@preact/signals';
import { persist } from 'signals-persist'

const count = persist(signal(0), 'count')

const App = () => {
return (


{count.value}

count.value++}
>
count++


)
}

export default App;

```

## License

[MIT](LICENSE)