npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pinia-chrome-storage

v1.0.5

Published

A Pinia plugin for Chrome storage synchronization

Readme

pinia-chrome-storage

npm version License: MIT

一个用于在 Chrome 扩展中同步 Pinia store 状态的插件。支持数据持久化、状态同步和懒加载。

特性

  • 🔄 自动同步 Pinia store 状态到 Chrome storage
  • ⚡ 支持懒加载,优化性能
  • 🔒 防止循环同步
  • 🛠️ 支持多种存储区域(local、sync、session、managed)
  • 📦 轻量级,无额外依赖
  • 🎯 完整的 TypeScript 支持

安装

npm install pinia-chrome-storage
# 或
yarn add pinia-chrome-storage
# 或
pnpm add pinia-chrome-storage

快速开始

import { createPinia } from 'pinia'
import { piniaChromeStoragePlugin } from 'pinia-chrome-storage'

const pinia = createPinia()
pinia.use(piniaChromeStoragePlugin({
  storage: 'local', // 可选:'local' | 'sync' | 'session' | 'managed',默认为 'local'
  prefix: 'my-app-' // 可选:存储键名前缀,用于避免命名冲突
}))

使用示例

import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', {
  state: () => ({
    count: 0
  }),
  actions: {
    increment() {
      this.count++
    }
  }
})

配置选项

| 选项 | 类型 | 默认值 | 描述 | |------|------|--------|------| | storage | 'local' | 'sync' | 'session' | 'managed' | 'local' | 使用的存储区域 | | prefix | string | '' | 存储键名前缀 |

工作原理

  1. 数据持久化:当 Pinia store 状态发生变化时,自动保存到 Chrome storage
  2. 状态同步:监听 Chrome storage 的变化并同步到 Pinia store
  3. 懒加载:只在首次访问 store 状态时才从 storage 加载数据
  4. 循环同步防护:通过特殊标记防止循环同步

注意事项

  • 确保在 Chrome 扩展环境中使用
  • 需要在 manifest.json 中声明适当的 storage 权限
  • 建议只同步必要的数据,避免存储过大的数据
  • 使用 prefix 避免与其他扩展的存储键名冲突

开发

# 安装依赖
npm install

# 构建
npm run build

# 代码检查
npm run lint

贡献

欢迎提交 Issue 和 Pull Request!

许可证

MIT