DE

Derive Valtio

derive-valtio

Derive util for Valtio

State Management
react
derive
valtio
state
derive-valtio
State Management
javascript
npm
frontend
open source
Stars
7
Weekly
799k
Open issues
2
Bundle
~25 kB

Installation

npm install derive-valtio

Code example

import { create } from "derive-valtio";

const useStore = create((set) => ({
  count: 0,
  inc: () => set((s) => ({ count: s.count + 1 })),
}));

export function Example() {
  const { count, inc } = useStore();
  return (
    <button type="button" onClick={inc}>
      Count: {count}
    </button>
  );
}

Pros & cons

Pros

  • Actively maintained by Daishi Kato
  • 799k weekly downloads. Battle tested
  • First-class TypeScript definitions
  • MIT licensed

Considerations

  • Adds roughly ~25 kB to your bundle
  • Needs client-only rendering in SSR frameworks
  • Not supported in React Native
  • 2 open issues on GitHub

FAQs

Alternatives & similar libraries