Skip to content

Pipel-React

Promise-like Reactive Streams for React

Simple, powerful, and elegant reactive programming with familiar Promise syntax

Pipel-React

Quick Example

tsx
import { usePipel } from 'pipel-react'

function Counter() {
  const [count, count$] = usePipel(0)

  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => count$.next(count + 1)}>Increment</button>
    </div>
  )
}

Installation

bash
npm install pipel-react pipeljs
bash
yarn add pipel-react pipeljs
bash
pnpm add pipel-react pipeljs

Why Pipel-React?

Traditional Approach

tsx
const [data, setData] = useState(null)
const [loading, setLoading] = useState(false)
const [error, setError] = useState(null)

const fetchData = async () => {
  setLoading(true)
  try {
    const res = await fetch('/api/data')
    setData(await res.json())
  } catch (err) {
    setError(err)
  } finally {
    setLoading(false)
  }
}

Pipel-React Approach

tsx
const { data, loading, error } = useFetch('/api/data', {
  immediate: true,
})

Learn More

Released under the MIT License.