Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including observable-hooks with all npm packages installed. Try it out:

require("react/package.json"); // react is a peer dependency. require("react-dom/package.json"); // react-dom is a peer dependency. require("rxjs/package.json"); // rxjs is a peer dependency. var observableHooks = require("observable-hooks")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

observable-hooks v2.3.5

React hooks for RxJS Observables. Simple, flexible, testable and performant.


npm-version npm bundle size Build Status Coverage Status

Commitizen friendly Conventional Commits JavaScript Style Guide code style: prettier


React hooks for RxJS Observables. Simple, flexible, testable and performant.

  • Seamless integration of React and RxJS.
    • Props and states to Observables.
    • Observables to states and props events.
    • Conditional rendering with stream of React Components.
    • Render-as-You-Fetch with React Suspense.
    • No tap hack needed. With Epic-like signature Observable operation is pure and testable.
  • Full-powered RxJS. Do whatever you want with Observables. No limitation nor compromise.
  • Fully tested. We believe in stability first. This project will always maintain a 100% coverage.
  • Tiny and fast. A lot of efforts had been put into improving integration. This library should have zero visible impact on performance.


React added hooks for reusing stateful logic.

Observable is a powerful way to encapsulate both sync and async logic.

Testing Observables is also way easier than testing other async implementations.

With observable-hooks we can create rich reusable Components with ease.

What It Is Not

This library is not for replacing state management tools like Redux but to reduce the need of dumping everything into global state.

Using this library does not mean you have to turn everything observable which is not encouraged. It plays well side by side with other hooks. Use it only on places where it's needed.

At First Glance

import * as React from 'react'
import { useObservableState } from 'observable-hooks'
import { timer } from 'rxjs'
import { switchMap, mapTo, startWith } from 'rxjs/operators'

const App = () => {
  const [isTyping, updateIsTyping] = useObservableState(

  return (
      <input type="text" onKeyDown={updateIsTyping} />
      <p>{isTyping ? 'Good you are typing.' : 'Why stop typing?'}</p>

// Logic is pure and can be tested like Epic in redux-observable
function transformTypingStatus(event$) {
  return event$.pipe(
    switchMap(() =>



yarn add observable-hooks


npm install --save observable-hooks


Read the docs at

Here is how I designed the API. Might give you a perspective on when use what.


Examples are in here. Play on CodeSandbox:

Note that there are also some useful utilities for common use cases to reduce garbage collection.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free