Next.js Example

Craft your next amazing library using

Harness the full potential of React 18 Server Components!
import useRGS from "r18gs";

const MY_KEY = "counter";

export const CounterController = () => {
  const [counter, setCounter] = useRGS(MY_KEY, 0);
  return (
    <input
      type="number"
      value={counter}
      onChange={e =>
        setCounter(Number(e.target.value))
      }
    />
  );
};

export const CounterDisplay = () => {
  const [counter] = useRGS(MY_KEY, 0);
  return <div>{counter}</div>;
};

All components below share the same state without any wrapper.

NPM Bundle Size

Counter Controller 1

Counter Display 1

0

Counter Controller 2

Counter Display 2

0
Fork Me on GitHub