TypeScript icon, indicating that this package has built-in type declarations

1.4.1 • Public • Published

Handle your component effects and side-effects in a clear and declarative fashion
by using asynchronous data streams (reactive programming).

Why? · Install · The gist · Learn · Contribute · Discuss

Library size MIT License

  • 🎳 Decentralised: attach effects and side-effects to your components, for better code splitting results
  • 🌅 Gradual: use on an existing component today, throughout your app tomorrow
  • 🚀 Reactive: leverage the power and benefits of reactive programming
  • 💾 Tiny: less than 2Kb minified and gzipped
  • 📝 Typed: written in TypeScript, fully typed integrations
  • ⚡️ Universal: supports React, React Native, Inferno and Preact

Refract makes reactive programming possible in React, React Native, Preact and Inferno, with only a single higher-order component or a single hook! You can choose to start using a tiny bit of reactive programming, or go full reactive. Refract allows you to:

We also provide a Redux integration, which can serve as a template for integrations with other libraries. With a single HoC, you can fully replace libraries like recompose, redux-observable, and react-redux to name a few!


Component-based architecture and functional programming have become an increasingly popular approach for building UIs. They help make apps more predictable, more testable, and more maintainable.

However, our apps don't exist in a vacuum! They need to handle state, make network requests, handle data persistence, log analytics, deal with changing time, and so on. Any non-trivial app has to handle any number of these effects. Wouldn't it be nice to cleanly separate them from our apps?

Refract solves this problem for you, by harnessing the power of reactive programming. For an in-depth introduction, head to Why Refract.


npm install --save refract-redux-callbag

Refract is available for a number of reactive programming libraries. For each library, a Refract integration is available for React, Inferno, Preact and Redux.

Available packages:

React Inferno Preact Redux
Callbag refract-callbag refract-inferno-callbag refract-preact-callbag refract-redux-callbag
Most refract-most refract-inferno-most refract-preact-most refract-redux-most
RxJS refract-rxjs refract-inferno-rxjs refract-preact-rxjs refract-redux-rxjs
xstream refract-xstream refract-inferno-xstream refract-preact-xstream refract-redux-xstream

The Gist

import { compose, createStore } from 'redux'
import { refractEnhancer } from 'refract-redux-rxjs'
const reducers = combineReducers({
    username: (state, action) => {
        if (action.type === 'USERNAME') {
            return action.payload
        return state
const store = createStore(reducers, {}, compose(refractEnhancer()))
const usernameActions$ = store.observe('USERNAME')
const username$ = store.observe(state => state.username)

Store enhancer

The Refract store enhancer adds an observe method which takes a single argument (action type or store selector) and returns an observable. Read observing redux for more details.

Learn Refract


Documentation is available at We aim to provide a helpful and thorough documentation: all documentation files are located on this repo and we welcome any pull request helping us achieve that goal.


We maintain and will grow over time a set of examples to illustrate the potential of Refract, as well as providing reactive programming examples:

Examples are illustrative and not the idiomatic way to use Refract. Each example is available for the four reactive libraries we support (RxJS, xstream, Most and Callbag), and we provide links to run the code live on All examples are hosted on this repo, and we welcome pull requests helping us maintaining them.


We welcome many forms of contribution from anyone who wishes to get involved.

Before getting started, please read through our contributing guidelines and code of conduct.



The Refract logo is available in the Logo directory.


Refract is available under the MIT license.


Everyone is welcome to join our discussion channel - #refract on the Reactiflux Discord server.



Package Sidebar


npm i refract-redux-callbag

Weekly Downloads






Unpacked Size

17.3 kB

Total Files


Last publish


  • troch
  • raptori
  • liamjdouglas
  • kyorkston