A pinia plugin for state persist.

Overview

Pinia Persists

A pinia plugin for state persist.

NPM version

English | 简体中文

Usage

Install

npm i pinia-persists

Use

import { persist } from 'pinia-persists'
import { createPinia } from 'pinia'

const pinia = createPinia()

// pinia use plugin
pinia.use(persist({ /* options */ }))

app.use(pinia)

Options

prefix

  • type: String
  • optional, default "pinia"
  • it is the prefix of the key to store the persisted state under, such as the store id is "test", that store key is "pinia_test" by default.

storage

  • type: Object

    interface Storage {
        readonly length?: number;
        clear?: () => void;
        getItem: (key: string) => string | null;
        key?: (index: number) => string | null;
        removeItem?: (key: string) => void;
        setItem: (key: string, value: string) => void;
        [name: string]: any;
    }
  • optional, default window.localStorage

  • it is the storage for state persist, you can choose localStorage, sessionStorage or your custom storage.

overwrite

  • type: Boolean
  • optional, default false
  • when app first loader or refresh, whether to overwrite the existing state with the output from state directly, instead of merging the two objects with deep merge.

License

MIT License © 2022 Dewey Ou

You might also like...

A helper to use immer as Solid.js Signal to drive state

Solid Immer A helper to use immer as Solid.js Signal to drive state. Installation $ npm install solid-immer Usage Use createImmerSignal to create a im

Nov 22, 2022

An event-driven architecture wrapper for Wechaty that applies the CQS principle by using separate Query and Command messages to retrieve and modify the bot state, respectively.

An event-driven architecture wrapper for Wechaty that applies the CQS principle by using separate Query and Command messages to retrieve and modify the bot state, respectively.

CQRS Wechaty An event-driven architecture wrapper for Wechaty that applies the CQS principle by using separate Query and Command messages to retrieve

Mar 23, 2022

Example code for MFE routing, shared state, build-time & runtime deploy video

Turborepo starter with pnpm This is an official starter turborepo. What's inside? This turborepo uses pnpm as a packages manager. It includes the foll

Nov 2, 2022

chain-syncer is a module which allows you to synchronize your app with any ethereum-compatible blockchain/contract state. Fast. Realtime. Reliable.

Chain Syncer Chain Syncer is a JS module which allows you to synchronize your app with any ethereum-compatible blockchain/contract state. Fast. Realti

Dec 15, 2022

On-chain snapshots of the whole blockchain state

📸 Snapshop 📸 Snapshop is a tool for creating on-chain snapshots of the whole blockchain state. It lets your smart contracts read the storage of any

Sep 26, 2022

🐻 Trying out the bear necessities for complex state management.

🐻 Zustand Demos My practice repository for the Zustand library--the bear necessities for complex state management. You can find some examples of how

Jul 2, 2022

Custom Vitest matchers to test the state of the DOM, forked from jest-dom.

vitest-dom Custom Vitest matchers to test the state of the DOM This library is a fork of @testing-library/jest-dom. It shares that library's implement

Dec 16, 2022

A tiny foundation that providing nested state-based routing for complex web application.

StateMan stateman: A tiny foundation that provides nested state-based routing for complex web applications. stateman is highly inspired by ui-router;

Dec 20, 2022

History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState

History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState. Supports jQuery, MooTools and Prototype.

Dec 26, 2022
Releases(v1.2.0)
Owner
Dewey Ou
Keep Learning..
Dewey Ou
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Next js boilerplate with redux toolkit, redux persist and axios

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Jorge Alberto Villarreal Gongora 5 Apr 25, 2022
🤖 Persist the Playwright executable between Netlify builds

?? Netlify Plugin Playwright Cache Persist the Playwright executables between Netlify builds. Why netlify-plugin-playwright-cache When you install pla

Hung Viet Nguyen 14 Oct 24, 2022
Nuxt3 template with Windicss + Pinia + Vitest + Playwright

Nuxt 3 Template Nuxt 3 template repository Look at the nuxt 3 documentation to learn more. Used Technologies Usage Setup Make sure to install the depe

Igor Makowski 5 Dec 14, 2022
Solid.js library adding a services layer for global shared state.

Solid Services Services are "global" objects useful for features that require shared state or persistent connections. Example uses of services might i

Maciej Kwaśniak 55 Dec 30, 2022
A tiny, reactive JavaScript library for structured state and tabular data.

A JavaScript library for structured state. Using plain old JavaScript objects to manage data gets old very quickly. It's error-prone, tricky to track

tinyplex 1.4k Jan 1, 2023
An event emitter that allows you to manage your global state

Thor Event Emitter Event emitter to manage your state. An event emitter that allows you to manage your global state. Instead of using global giant obj

Jalal 6 Apr 18, 2022
State based input library for the browser

Inp State based input library for the browser

null 2 Mar 23, 2022