Awesome Open Source
Awesome Open Source


API ⇆ Trux ➝ UI

Unidirectional data layer for reactive user interfaces.

Build Status Coverage Status Dependency Status npm version


Trux is an easy-to-use, lightweight and effective way of managing mutable data for your client side JavaScript app.

With its focus placed on enabling the creation of fully customisable bridges between your API and UI, Trux provides convenient and safe ways to mutate data and synchronise these mutations with your components.

With Trux, your data stores become the sources of truth for your app's data driven user interfaces. All you need to do is create some stores, connect components to them and let it do the work.

While it was designed with React and a REST API in mind, Trux can also be used with other view libraries and API systems such as Vue and GraphQL.

Want to learn more? Checkout the quickstart guide below or get an in-depth look by reading the docs.


npm i -S trux


In order to support older browsers you'll need some polyfills


In Trux, your client side data is kept in stores called models or collections. You connect components to these stores and ask the stores to perform data changes. Your stores can persist these changes to their connected components. You can choose to make these updates either optimistic or pessimistic.

Here's the basic gist, without considering requests to an API

import { Model } from 'trux';

// First we're going to create a Counter model with some starting data.
// By extending the Trux Model class, we get all the functionality we need plus we can add custom methods,
// like the increment and decrement methods which mutate the state of the model.
class Counter extends Model {
  constructor() {
    super({ value: 0 });

  increment() {;
    return this;

  decrement() {;
    return this;

// Instantiate the store
const store = new Counter();

// Now we are going to create a mock component to connect to our store.
// We need to declare a unique truxid and a storeDidUpdate method to receive updates from the store.
const component = {
  truxid: 'TICKER',
  storeDidUpdate: () => {

// connect the component to the store.
// call the increment and decrement methods then chain persist to see the new value get logged.
store.increment().persist(); // 1
store.increment().persist(); // 2
store.decrement().persist(); // 1

Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,074,125
Reactjs (164,470
Vue (67,149
Rest Api (16,527
Graphql (15,855
Reactive (5,627
State Management (1,914
Unidirectional (284
Unidirectional Data Flow (110