# pinia-use-persist

> Easy to use persist plugin with configurable encryption, Currently in development, but already used in real production for simple scenarios

Latest version **0.0.21** (published 2022-06-23) · 0 weekly downloads

## Install

```sh
npm install pinia-use-persist
pnpm add pinia-use-persist
yarn add pinia-use-persist
bun add pinia-use-persist
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.21 |
| Published | 2022-06-23 |
| First published | 2022-05-24 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | deilzy |
| Keywords | pinia, persist, pinia-persist, pinia-persist-encryption, vue3 |

## Links

- npm: https://www.npmjs.com/package/pinia-use-persist
- npm.io page: https://npm.io/package/pinia-use-persist

## Dependencies (2)

- [pinia](https://npm.io/package/pinia.md) ^2.0.14
- [crypto-js](https://npm.io/package/crypto-js.md) ^4.1.1

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 0.0.21 (latest) — 2022-06-23
- 0.0.2 — 2022-05-26
- 0.0.1-9.1 — 2022-05-26
- 0.0.19 — 2022-05-25
- 0.0.18 — 2022-05-25
- 0.0.17 — 2022-05-25
- 0.0.16 — 2022-05-25
- 0.0.15 — 2022-05-25
- 0.0.14 — 2022-05-25
- 0.0.13 — 2022-05-24
- 0.0.12 — 2022-05-24
- 0.0.11 — 2022-05-24
- 0.0.1 — 2022-05-24

## README

# Documentation

## Install
```typescript
npm i pinia-use-persist
```

## Use

main.ts

```typescript

import {createPinia} from "pinia";

import {usePersist} from 'pinia-use-persist'

const pinia = createPinia()

pinia.use(usePersist)

app.use(pinia)

```

store.ts
```typescript
export const useStore = defineStore('main', {
  state: () => ({
    counter: 0,
  }),
  persist:{
    enabled: true,
    key: ['counter'],
    encryptionKey: 'my-store',
    storage: sessionStorage,
  }
})
```


```vue

<script setup lang='ts'>
import { useStore } from '@/store/store.ts'
const store = useStore()

const add = () => {
  store.$patch((state) => {
    state.counter = state.counter + 1
  })
}
</script>

<template>
  <div>
    <p>{{store.$state.counter}}</p>
    <button @click="add">+</button>
  </div>
</template>

```

### Note: 📢

When you add new key-value in store.ts file, you need to reload the page to achieve persistence.

### Plan 📢

1. Logger
2. Encryption
3. ...

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