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

@ryujaewan/restate

v2.0.1

Published

React State (`@ryujaewan/restate` is a lightweight library that simplifies state management in React applications. It enables easy sharing and updating of state across multiple components.)

Readme

Restate

Restate는 React 애플리케이션에서 전역 상태 관리를 간단하고 효율적으로 구현할 수 있는 라이브러리입니다. 복잡한 설정 없이 직관적인 API로 컴포넌트 간 상태 공유가 가능합니다.

특징

  • 🚀 간단한 API - 복잡한 보일러플레이트 코드 없이 직관적인 사용법
  • 🔄 자동 업데이트 - 상태 변경 시 구독 컴포넌트 자동 리렌더링
  • 🎯 선택적 업데이트 - 다양한 업데이트 전략으로 성능 최적화
  • 🧠 동적 구독 - 컴포넌트가 마운트될 때만 상태 업데이트 구독
  • 🔌 외부 데이터 연동 - 외부 데이터 소스와 쉽게 연결

설치

npm install @ryujaewan/restate

또는

yarn add @ryujaewan/restate

기본 사용법

import { restate } from '@ryujaewan/restate';

// 전역 상태 생성
const useCounter = restate(0);

// 컴포넌트에서 사용
function Counter() {
  const count = useCounter();
  
  return (
    <div>
      <p>카운트: {count}</p>
      <button onClick={() => useCounter.set(count + 1)}>증가</button>
    </div>
  );
}

고급 사용법

객체 상태 관리

import { restate } from '@ryujaewan/restate';

// 객체 상태 생성
const useUserState = restate(
  { name: '홍길동', age: 30, preferences: { theme: 'dark' } }
);

function UserProfile() {
  const user = useUserState();
  
  return (
    <div>
      <h2>{user.name}</h2>
      <p>나이: {user.age}</p>
      <p>테마: {user.preferences.theme}</p>
      
      <button onClick={() => useUserState.set({ ...user, age: user.age + 1 })}>
        생일 축하!
      </button>
    </div>
  );
}

외부 데이터 연동

import { restate } from '@ryujaewan/restate';

// 웹소켓 연결과 상태 동기화
const useSocketMessages = restate([], ({ setState }) => {
  const socket = new WebSocket('wss://example.com/socket');
  
  socket.onmessage = (event) => {
    const message = JSON.parse(event.data);
    setState(prev => [...prev, message]);
  };
  
  // 정리 함수 반환
  return () => socket.close();
});

컴포넌트별 업데이트 조건 설정

function SpecificComponent() {
  // 이 컴포넌트는 name이 변경될 때만 리렌더링
  const user = useUserState((prev, next) => prev.name !== next.name);
  
  return <div>{user.name}</div>;
}

API 레퍼런스

restate(initialValue, updater?)

전역 상태를 생성합니다.

  • initialValue: 초기 상태 값
  • updater: 상태 업데이트 로직을 포함하는 선택적 함수

반환된 훅

  • useRestateFn(): 컴포넌트에서 상태를 구독하는 훅
  • useRestateFn.get(): 현재 상태 값을 가져오는 함수
  • useRestateFn.set(newValue): 상태를 업데이트하는 함수

예제 프로젝트

더 많은 예제는 GitHub 저장소에서 확인하세요.

라이선스

MIT


Restate로 React 상태 관리의 복잡성을 줄이고, 더 효율적인 애플리케이션을 만들어보세요! 🚀