Skip to content

rkrupinski/stan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

429 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stan

CI NPM Version Bundle size

Minimal, type-safe state management

Install

npm install @rkrupinski/stan

Quick start

import { atom, selector } from "@rkrupinski/stan";
import { useStan, useStanValue } from "@rkrupinski/stan/react";

const count = atom(0);
const doubled = selector(({ get }) => get(count) * 2);

function Counter() {
  const [value, setValue] = useStan(count);
  const double = useStanValue(doubled);

  return (
    <>
      <button onClick={() => setValue(v => v + 1)}>Count: {value}</button>
      <p>Doubled: {double}</p>
    </>
  );
}