# Storeon

> An event-based, Redux-like state manager for React, Preact, Angular, Vue, and Svelte.

- URL: https://evilmartians.com/opensource/storeon
- GitHub: https://github.com/storeon/storeon
- Authors: Andrey Sitnik

---

Storeon is an event-based, Redux-like state manager for React, Preact, Angular, Vue, and Svelte. It's super small (180 bytes minified), fast, and modular.

* **Small.** 180 bytes (minified and gzipped). No dependencies. It uses [Size Limit][Size Limit] to control size.
* **Fast.** It tracks what parts of the state were changed and re-renders components only based on the changes.
* **Hooks.** The same Redux reducers.
* **Modular.** API created to move business logic away from React components.

Read more about Storeon features:

*Read also Evil Martians' article*: https://evilmartians.com/chronicles/storeon-redux-in-173-bytes

```js
import { createStoreon } from 'storeon'

// Initial state, reducers and business logic are packed in independent modules
let count = store => {
  // Initial state
  store.on('@init', () => ({ count: 0 }))
  // Reducers returns only changed part of the state
  store.on('inc', ({ count }) => ({ count: count + 1 }))
}

export const store = createStoreon([count])
```

```js
import { useStoreon } from 'storeon/react' // or storeon/preact

export const Counter = () => {
  // Counter will be re-render only on `state.count` changes
  const { dispatch, count } = useStoreon('count')
  return <button onClick={() => dispatch('inc')}>{count}</button>
}
```

```js
import { StoreContext } from 'storeon/react'

render(

  ,
  document.body
)
```

[Size Limit]: https://evilmartians.com/opensource/size-limit
