# hydux
**Repository Path**: zane_young/hydux
## Basic Information
- **Project Name**: hydux
- **Description**: An Elm-like redux alternative inspired by Hyperapp, Elmish, Elm, Redux, etc. Working with any vdom library!
- **Primary Language**: TypeScript
- **License**: MIT
- **Default Branch**: master
- **Homepage**: https://my.oschina.net/ZaneYoung/blog/1587189
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2017-12-09
- **Last Updated**: 2021-06-20
## Categories & Tags
**Categories**: javascript-toolkits
**Tags**: None
## README
# Hydux
[](https://travis-ci.org/hydux/hydux) [](https://www.npmjs.com/package/hydux) [](https://www.npmjs.com/package/hydux)
A React-Compatible fork of [Hyperapp](https://github.com/hyperapp/hyperapp), inspired by [Elmish](https://github.com/fable-elmish/elmish), Elm, Redux, etc. Working with any vdom library!
## Features
* [hyperapp](https://github.com/hyperapp/hyperapp) compatible API
* Support any vdom library, including react ([official support](https://github.com/hydux/hydux-react))
* [Official support for react-router](https://github.com/hydux/hydux-react-router)
* Hot reload (hmr), logger, persist, [Redux Devtools with time traveling](https://github.com/zalmoxisus/redux-devtools-extension), [ultradom](https://github.com/jorgebucaran/ultradom)(1kb vdom), **\*\*All in One\*\***, easily setup all these fancy stuff without pain!
* Elm-like side effect manager and subscribe API

## [Try it online!](https://codepen.io/zaaack/pen/zPgodL)
## Install
```sh
yarn add hydux # or npm i hydux
```
## Quick Example
Let's say we got a counter, like this.
```js
// Counter.js
export default {
init: () => ({ count: 1 }),
actions: {
down: () => state => ({ count: state.count - 1 }),
up: () => state => ({ count: state.count + 1 })
},
view: (state: State, actions: Actions) =>
{state.count}
}
```
Then we can compose it in Elm way, you can easily reuse your components.
```js
import _app from 'hydux'
import withPersist from 'hydux/lib/enhancers/persist'
import withultradom, { h, React } from 'hydux/lib/enhancers/ultradom-render'
import Counter from './counter'
// let app = withPersist({
// key: 'my-counter-app/v1'
// })(_app)
// use built-in 1kb ultradom to render the view.
let app = withultradom()(_app)
if (process.env.NODE_ENV === 'development') {
// built-in dev tools, without pain.
const devTools = require('hydux/lib/enhancers/devtools').default
const logger = require('hydux/lib/enhancers/logger').default
const hmr = require('hydux/lib/enhancers/hmr').default
app = logger()(app)
app = devTools()(app)
app = hmr()(app)
}
const actions = {
counter1: Counter.actions,
counter2: Counter.actions,
}
const state = {
counter1: Counter.init(),
counter2: Counter.init(),
}
const view = (state: State, actions: Actions) =>