DEV Community

jav974
jav974

Posted on

Introducing react-refsignal: A lightweight React hook for reactive state

Hey Devs! ๐Ÿ‘‹

I recently open-sourced a small utility called react-refsignal, a lightweight React hook library inspired by Preact Signals. It lets you create reactive references that you can watch for update in your components. It works exactly like useRef, useEffect, useMemo, but with direct invocation like signals. You can then trigger effects, recomputations, or re-renders where needed.

Why I built it

Preact Signals are great, but they introduce a different pattern not particularly easy to integrate into a codebase. With RefSignal however i could enjoy working with regular react api, well through new hooks but with same intended behaviour.

Features

  • ๐Ÿ” Reactive refs that can be updated, and watched for
  • ๐Ÿง  Familiar API for React developers
  • โšก Lightweight and dependency-free
  • ๐Ÿงช Great for building reactive UIs with minimal code

Try it out

Iโ€™d love to hear your thoughtsโ€”feedback, issues, or even just a star if you find it useful. Thanks for reading, and happy coding! ๐Ÿš€

Top comments (0)