Rematch.js v2 released
Tags: rematchjs, react, redux, rematch
Published: 2021-02-01 14:12:49

[Rematch](https://github.com/rematch/rematch) has been created a few years ago by [Shawn McKay](https://github.com/ShMcK) and Blair Bodnar, a pair of canadian programmers. It's a tiny but super powerful wrapper around Redux that reduces tons of boilerplate that Redux needs to operate. 

For example, async actions in Redux needs `redux-thunk` or `redux-saga`, in Rematch are just native async/await methods, with zero dependencies.

Rematch has been downloaded 2 millions times in 2 years and used by big companies like Adobe or Alibaba in production environments with any issues at all.

### Example of a Rematch Model

In this example we're using typescript, initializing a empty state players which will contain an array of players that will come from an external API. 

```ts
type PlayersState = {
	players: PlayerModel[]
}

export const players = createModel<RootModel>()({
	state: {
		players: [],
	} as PlayersState,
	reducers: {
		SET_PLAYERS: (state: PlayersState, players: PlayerModel[]) => {
			return {
				...state,
				players,
			}
		},
	},
	effects: (dispatch) => {
		const { players } = dispatch
		return {
			async getPlayers(): Promise<any> {
				let response = await fetch('https://www.balldontlie.io/api/v1/players')
				let { data }: { data: PlayerModel[] } = await response.json()
				players.SET_PLAYERS(data)
			},
		}
	},
})
```

In a few lines you can get easily asynchronous calls to an external API and data stored globally. It's amazing, with Redux you will needs tons of boilerplate, libraries and extra configuration.

I'm glad to write here that Rematch has received a full rework of his codebase that improved even more the library.

### What we did in 6 months of iteration plan:

- We migrated all our codebase to Typescript. (Also this means that we're 100% percent compatible with latest Typescript features and we get intellisense of states, effects, reducers) everything is typed and helps a lot to avoid regressions)
- Introduced a new Plugin API for making it easier creating custom plugins for Rematch.
- We moved to a monorepo with `yarn workspaces` and `lerna`.
- Reduced bundle size of EVERY package that Rematch owns.

|package|old version|latest version|diff|
|-------|-----------|--------------|----|
|@rematch/core|![](https://img.shields.io/bundlephobia/min/@rematch/core@1.4.0)|![](https://img.shields.io/bundlephobia/min/@rematch/core)|-106.12%|
|@rematch/loading|![](https://img.shields.io/bundlephobia/min/@rematch/loading@1.2.1)|![](https://img.shields.io/bundlephobia/min/@rematch/loading)|-76.36%|
|@rematch/updated|![](https://img.shields.io/bundlephobia/min/@rematch/updated@0.1.5)|![](https://img.shields.io/bundlephobia/min/@rematch/updated)|-87.18%|
|@rematch/select|![](https://img.shields.io/bundlephobia/min/@rematch/select@2.0.5)|![](https://img.shields.io/bundlephobia/min/@rematch/select)|-24.24%|
|@rematch/persist|![](https://img.shields.io/bundlephobia/min/@rematch/persist@1.1.6)|![](https://img.shields.io/bundlephobia/min/@rematch/persist)|-44.33%|
|@rematch/immer|![](https://img.shields.io/bundlephobia/min/@rematch/immer@1.2.0)|![](https://img.shields.io/bundlephobia/min/@rematch/immer)|-189.75%|

- Also, we migrated our documentation to [Docusaurus v2](https://v2.docusaurus.io) and bought a domain for Rematch!

https://rematchjs.org

We know that in 2021 Redux isn't that cool as `React.useContext, React.useReducer`, or other alternatives of state-management, but we keep working hard inside Rematch to keep the essence of simplicity and still be in conjunction with Redux to provide an easy and a powerful state-management solution to every project.

Feel free to try Rematch on your new projects or take a look at any of our [examples](https://rematchjs.org/examples/). 

Happy new year everyone!!