mcpField
V
valtio-define

valtio-define

github.com/hairyfDevelopment26750 installsUpdated 2w ago
Repository

About valtio-define

valtio-define is a Valtio-based state management library for React developers. It creates reactive stores with state, actions, and getters through a Pinia-like API, with TypeScript support.

Key features

  1. 01Reactive store factory
  2. 02State, actions, and getters
  3. 03React hook for store access
  4. 04State subscriptions and patches
  5. 05Plugins and persistent state

Use cases

  1. 01Organizing shared React application state
  2. 02Subscribing to store changes
  3. 03Persisting state through a plugin

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/hairyf/skills --skill valtio-define

After installing, type/valtio-definein Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

LICENSE.md
SYNC.md
references/
advanced-patch.md
advanced-signal.md
advanced-store-to-state.md
advanced-subscribe.md
core-define-store.md
core-types.md
core-use-store.md
feature-persistent-plugin.md
feature-plugin-system.md

Details

From the project README

Based on valtio-define v1.0.1. A Valtio-based state management library with Pinia-like API for React applications.

Overview

valtio-define provides a factory function for creating reactive stores with state, actions, and getters. Built on top of Valtio, it offers a familiar API similar to Pinia with full TypeScript support.

Core References

TopicDescriptionReference
defineStoreCore API for creating reactive storescore-define-store
useStoreReact hook for accessing store statecore-use-store
TypesTypeScript types and interfacescore-types

Advanced Features

TopicDescriptionReference
SubscriptionsSubscribe to state changesadvanced-subscribe
PatchUpdate state with patch operationsadvanced-patch
SignalJSX component for inline reactive valuesadvanced-signal
Store to StateConvert store to useState-like hooksadvanced-store-to-state

Features

TopicDescriptionReference
Plugin SystemExtend stores with pluginsfeature-plugin-system
Persistent PluginPersist state to storagefeature-persistent-plugin

Quick Start

import { defineStore, useStore } from 'valtio-define'

const store = defineStore({
  state: () => ({ count: 0 }),
  actions: {
    increment() { this.count++ },
  },
  getters: {
    doubled() { return this.count * 2 },
  },
})

function Counter() {
  const state = useStore(store)
  return (
    <div>
      <div>Count: {state.count}</div>
      <div>Doubled: {state.doubled}</div>
      <button onClick={store.increment}>Increment</button>
    </div>
  )
}

Comments

Markdown supported