Skip to content

Latest commit

 

History

History

README.md

@blac/preact

Preact bindings for BlaC — same useBloc API as @blac/react, built for Preact 10+.

Documentation · npm

Installation

pnpm add @blac/preact @blac/core

Requires Preact 10.17+.

Usage

import { Cubit } from '@blac/core';
import { useBloc } from '@blac/preact';

class CounterCubit extends Cubit<{ count: number }> {
  constructor() {
    super({ count: 0 });
  }
  increment = () => this.emit({ count: this.state.count + 1 });
}

function Counter() {
  const [state, counter] = useBloc(CounterCubit);
  return <button onClick={counter.increment}>{state.count}</button>;
}

The hook signature and options are identical to @blac/react — see the @blac/react README for the full useBloc API including tracking modes, instanceId, onMount/onUnmount, and manual dependencies.

License

MIT