# fluxgate

> ## Architecture

Latest version **1.3.0** (published 2026-02-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install fluxgate
pnpm add fluxgate
yarn add fluxgate
bun add fluxgate
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2026-02-21 |
| First published | 2020-07-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 18.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | omegascorp |

## Links

- npm: https://www.npmjs.com/package/fluxgate
- Repository: https://github.com/codetraceio/fluxgate
- Homepage: https://github.com/codetraceio/fluxgate#readme
- Issues: https://github.com/codetraceio/fluxgate/issues
- npm.io page: https://npm.io/package/fluxgate

## Dependencies (1)

- [events](https://npm.io/package/events.md) ^3.1.0

## Recent versions

- 1.3.0 (latest) — 2026-02-21
- 1.2.0 — 2022-07-30
- 1.1.0 — 2022-06-04
- 1.0.0 — 2021-05-06
- 0.3.1 — 2021-01-04
- 0.3.0 — 2021-01-04
- 0.2.1 — 2020-09-05
- 0.2.0 — 2020-07-03

## README

# Fluxgate - a flux store

## Architecture

Fluxgate consists of 2 main parts - **store** and **actions**. **Store** - contains the data and changes the data, **actions** are triggering store change. Store and actions are connected with an **event emitter**.

## Usage example

```js
import * as React from "react";
import { createStore, createEmitter, createActions } from "fluxgate";
import { useState, StoreProvider } from "fluxgate-hooks";

interface User {
  id: string;
  login: string;
}

interface UserStore {
  user: User;
  loading: boolean;
}

const Stores = {
  user = "user",
};

const userEmitter = createEmitter();

const userStore = createStore<UserStore>(userEmitter, {
  user: null,
  loading: false,
}, "user");

function loadUser(id: string) {
  userStore.setState({ loading: true });
  readUserFromApi(id).then((user) => { // readUserFromApi - is not defined in the example
    userStore.setState({
      user,
      loading: false,
    });
  });
}

const userActions = createActions(userStore, {
  loadUser,
});

function AppContainer() {
  const userState = useStore<UserStore>(Stores.user);
  
  if (userState.user) {
    return (
      <StoreProvider
        stores={{
          [Stores.user]: userStore,
        }}
        actions={{
          [Stores.user]: userActions,
        }}
      >
        <div>
          {user.id} {user.login}
        </div>
      </StoreProvider>
    );
  }

  return (
    <button onClick={userActions.loadUser}>Load User</button>
  );
}

ReactDom.render(<AppContainer />, window.document.querySelector('.app'));
```

---
_Source: https://npm.io/package/fluxgate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
