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)