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

xds

v1.1.2

Published

A simple state management library for Vue 3

Readme

xds

Documentation

A lightweight, Pinia-like state management library for Vue 3. It provides a simple Setup Store pattern with built-in persistence support and essential helpers.

Features

  • 📦 Lightweight: Zero dependencies (only Vue).
  • Reactive: Built on Vue 3's Reactivity API.
  • 🛠 Setup Stores: Define stores using standard Vue Composition API.
  • 🔌 Pinia Compatible API: Familiar methods like $patch, $reset, $state.
  • 🧩 No Boilerplate: No actions/mutations separation. Just functions.
  • 🔧 TypeScript: First-class type support.
  • 🚧 SSR & HMR: Server-Side Rendering and Hot Module Replacement are currently WIP.

Installation

npm install xds
# or
pnpm add xds

Usage

1. Install Plugin (Recommended)

For sharing state across your app and ensuring SSR/Multi-app isolation, install the plugin:

import { createApp } from 'vue'
import { xds } from 'xds'
import App from './App.vue'

const app = createApp(App)
app.use(xds())
app.mount('#app')

2. Define a Store

xds uses the Setup Store pattern. You define state using ref or reactive, and actions as regular functions.

import { defineStore } from 'xds'
import { ref, computed } from 'vue'

export const useCounterStore = defineStore('counter', () => {
  // State
  const count = ref(0)
  const name = ref('Eduardo')

  // Getters
  const doubleCount = computed(() => count.value * 2)

  // Actions
  function increment() {
    count.value++
  }

  function $reset() {
    count.value = 0
  }

  return { count, name, doubleCount, increment, $reset }
})

3. Use in Component

<script setup>
import { useCounterStore } from './store'
import { storeToRefs } from 'xds'

const store = useCounterStore()

// Destructuring with reactivity
const { count, doubleCount } = storeToRefs(store)

function add() {
  store.increment()
}
</script>

<template>
  <button @click="add">Count: {{ count }} (Double: {{ doubleCount }})</button>
</template>

Core Concepts & Guide

defineStore (Hook Pattern)

  • defineStore: Returns a hook function (e.g., useStore).
    • When to use: In most application code, especially within Vue components. It follows the standard Vue/Pinia pattern and allows for lazy initialization. The store is created only when useStore() is first called.
    • Example: const useStore = defineStore(...)const store = useStore()

Plugin Installation

Installing the plugin via app.use(xds()) is strongly recommended for modern Vue apps.

  • Why use it: It ensures the store registry is properly provided to your application context.
    • SSR Safe: Essential for preventing state pollution between requests in Server-Side Rendering.
    • State Isolation: Ensures isolated store instances for multiple Vue apps on the same page.
    • Leak Detection: The library warns if you use defineStore without an active registry context (when xds is used).
  • Without it: Stores fall back to a global module-level registry (Singleton Mode), which is simpler but less safe for complex environments.

API Reference

Detailed API documentation is available in the online documentation.

Core Methods

  • $patch(partialStateOrMutator): Update state.
  • $reset(): Reset state (requires implementation).
  • $state: Access or replace the entire state object.
  • $dispose(): Stop the store's effect scope.

Core Functions

  • defineStore(id, setup): Create a hook to access a store.
  • xds(): Create a new store registry for the app.

Utilities

  • storeToRefs(store): Destructures state while preserving reactivity.

Persistence

XDS includes a powerful built-in persistence plugin.

Setup

Register the plugin in your app entry point:

import { createApp } from 'vue'
import { xds, persistence } from 'xds'

const app = createApp(App)

app.use(
  xds({
    plugins: [
      persistence({
        // Enable persistence for specific stores by ID
        enable: ['counter', 'auth'],
      }),
    ],
  }),
)

Advanced Configuration (Per-Store)

You can customize persistence behavior for each store using strategies. For example, persisting different keys for different stores:

persistence({
  enable: ['aStore', 'bStore'],
  strategies: {
    aStore: {
      paths: ['token'], // Only persist 'token' for aStore
    },
    bStore: {
      paths: ['boken'], // Only persist 'boken' for bStore
      storage: sessionStorage, // Use sessionStorage for this store
    },
  },
})

For full documentation, visit the Persistence Guide.

Development

Scripts

  • pnpm build: Build the library
  • pnpm test: Run tests (Vitest)
  • pnpm test:coverage: Run tests with coverage
  • pnpm lint: Lint code
  • pnpm format: Format code

License

MIT