https://github.com/litingyes/pinia-plugin-unstorage
The best persistence plugin for pinia.
https://github.com/litingyes/pinia-plugin-unstorage
nuxt persistent-storage pinia vue
Last synced: about 1 year ago
JSON representation
The best persistence plugin for pinia.
- Host: GitHub
- URL: https://github.com/litingyes/pinia-plugin-unstorage
- Owner: litingyes
- License: mit
- Created: 2025-02-19T14:40:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-25T14:33:47.000Z (about 1 year ago)
- Last Synced: 2025-03-30T11:22:23.924Z (about 1 year ago)
- Topics: nuxt, persistent-storage, pinia, vue
- Language: TypeScript
- Homepage:
- Size: 353 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-vue - pinia-plugin-unstorage - The best persistence plugin with unjs/unstorage for pinia. (Components & Libraries / Utilities)
- awesome-vue - pinia-plugin-unstorage - The best persistence plugin with unjs/unstorage for pinia. (Components & Libraries / Utilities)
README
# pinia-plugin-unstorage
The best persistence plugin for pinia.
> [!TIP]
> The persistence logic of this plugin is implemented based on [unstorage](https://unstorage.unjs.io/), which provide unified key-value storage API. Based on this, you can even persist the data to the database
## Install
```bash
pnpm add pinia-plugin-unstorage
```
## Usage
### Vue app
```ts
import { createPinia } from 'pinia'
import { createPiniaUnstorage } from 'pinia-plugin-unstorage'
const pinia = createPinia()
pinia.use(createPiniaUnstorage({
// UnstorageOptions
}))
```
### Nuxt app
```ts
export default defineNuxtConfig({
modules: ['@pinia/nuxt', 'pinia-plugin-unstorage/nuxt'],
piniaUnstorage: {
// UnstorageOptions
},
})
```
## Options
### Plugin options
```ts
interface UnstorageOptions {
namespace: string // prefix str to as storage key
driver: Driver // the storage instance in unstorage
}
```
### Store options
```ts
export const useStore = defineStore('store', () => {
// ...
}, {
unstorage: {
pick: [], // string[], state keys picked to storage
omit: [] // string[], state keys omitted fot storage
}
})
```