Skip to content

@wirestate/react [monorepo] [docs]

npmlicense

React bindings for Wirestate containers.

Use this package to provide a Wirestate container to a React tree, inject services from components, and register component-scoped event, command, and query handlers.

Install

bash
npm install @wirestate/core @wirestate/react

Start

tsx
import { Injectable } from "@wirestate/core";
import { ContainerProvider, useInjection } from "@wirestate/react";

@Injectable()
class CounterService {
  public count = 0;
}

function CounterView() {
  const counter = useInjection(CounterService);

  return <span>{counter.count}</span>;
}

export function Application() {
  return (
    <ContainerProvider config={{ bindings: [CounterService] }}>
      <CounterView />
    </ContainerProvider>
  );
}

What Is Included

This package wires services into React. It does not make service fields reactive by itself; pair it with @wirestate/react-mobx, @wirestate/react-signals, or your own React reactivity adapter when components need to re-render from service changes.

Learn More

License

MIT