
Product
Introducing Webhook Events for Pull Request Scans
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Enhances Pinia stores with advanced features such as persistence, encryption, and store extension. Simplifies state management and ensures data security for Vue.js and Nuxt applications.
epps
- Extends and Persist Pinia Storeepps
is a plugin for the Pinia state management library in Vue.js. It extends Pinia stores with advanced features such as persistence, encryption, and store extension. It simplifies state and action management while ensuring sensitive data is protected and enabling seamless integration of parent-child store relationships.
By using the epps
plugin, you can create more powerful and flexible Pinia stores while ensuring data security and simplifying state management in your Vue.js or Nuxt application.
The plugin allows you to extend existing stores by adding additional actions and states. It also supports parent-child store relationships, enabling stores to inherit and share state and actions seamlessly.
The plugin enables persisting the state of stores in IndexedDB or LocalStorage. It ensures that data is retained between user sessions and provides options to exclude specific keys from persistence.
The plugin provides encryption for persisted state properties in the browser. This ensures that critical data stored in the browser is secure. However, the data remains readable within the store as it is decrypted when retrieved from LocalStorage or IndexedDB.
Follow these steps to quickly get started with the epps
plugin:
Install the plugin using npm or yarn:
npm install epps
# or
yarn add epps
To use the plugin, simply import it and add it to your Pinia instance.
All createPlugin function parameters are optional.
In the examples below, the environment variable CRYPT_KEY
must be replaced with string. It's used for encrypting data persisted in the browser.
// ./main.js
import { createPinia } from 'pinia'
import { createPlugin } from 'epps'
const pinia = createPinia()
const epps = createPlugin(
'localStorage', // define another database name to use IndexedDB
import.meta.env.CRYPT_KEY
)
pinia.use(epps)
// ./plugins/epps-plugin.client.ts
import type { Pinia, PiniaPlugin, PiniaPluginContext } from "pinia"
import { createPlugin } from 'epps'
export default defineNuxtPlugin({
name: 'eppsPlugin',
async setup({ $pinia }) {
($pinia as Pinia).use(
createPlugin(
'localStorage', // define another database name to use IndexedDB
useRuntimeConfig().public.cryptKey
)
)
}
})
useListsStore
The useListsStore
store demonstrates how to create a collection-based store using the useCollectionStore
store, which is integrated into the Epps plugin. This allows you to manage collections of items in your project seamlessly.
import { ref } from "vue";
import { defineEppsStore, getExtendedStore, useCollectionStore } from 'epps';
import type { List, ListsState, ListsStoreMethods } from "../types/list";
export const useListsStore = (id?: string) => defineEppsStore<ListsStoreMethods, ListsState>(
id ?? 'listsStore',
() => ({
newList: (list: List) => {
const store = getExtendedStore<ListsStoreMethods, ListsState>()
store.addItem({ ...list, id: store.lists.length + 1})
}
}),
{
actionsToRename: { getItems: 'getLists' },
parentsStores: [new ParentStore('listsCollection', useCollectionStore)],
persist: { watchMutation: true },
propertiesToRename: { items: 'lists' }
}
)()
...
const epps = new Epps({
parentsStores: [ new ParentStore('listsCollection', useCollectionStore) ],
persist: true // Store persisted manually. Use “watchMutation” to persist each time the State is modified.
})
export const useListsStore = (id?: string) => defineEppsStore<CollectionStoreMethods, CollectionState<List>>(
id ?? 'listsStore',
() => ({
getLists: () => {
const collectionStore = epps.getStore<CollectionStoreMethods, CollectionState<List>>(0, id ?? defaultStoreId)
return collectionStore()?.getItems()
}
}),
epps
)();
In this example:
useCollectionStore
is a utility provided by the Epps plugin to manage collections of items.useListsStore
store extends useCollectionStore
to manage a collection of lists with persistence enabled.To use the useListsStore
store in a Vue component, you can import and use it as follows:
<script setup>
import { useListsStore } from '../stores/lists'
import type { List } from "../models/liste"
const listsStore = useListsStore()
listsStore.remember()
</script>
<template>
<div>
<h1>Lists</h1>
<ul>
<li v-for="list in listsStore.items" :key="list.id">
{{ list.name }} (Type: {{ list.type }})
</li>
</ul>
</div>
</template>
This example shows how to add a new list and retrieve all lists from the useListsStore
store. The useCollectionStore
integration simplifies collection management in your project.
To ensure functional stability, the Epps plugin is tested with vitest. Its coverage rate is over 90%. To test Pinia stores using epps, you need to use the createPluginMock function. This function provides a mock implementation of epps plugin, allowing you to simulate its behavior during testing.
[0.4.7] - 2025-10-13
Improved plugin performance and simplified setting of persistence options.
FAQs
Enhances Pinia stores with advanced features such as persistence, encryption, and store extension. Simplifies state management and ensures data security for Vue.js and Nuxt applications.
The npm package epps receives a total of 399 weekly downloads. As such, epps popularity was classified as not popular.
We found that epps demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.