Rematch API Reference

The API exposed by Rematch is very simple and it is based around the init method. It creates and returns a Rematch store, which is essentially a Redux store with a few additional properties and extra features.

  • To use Rematch in your project, you need to understand how to define models that are passed to the init configuration.
  • If you are planning to migrate from the plain Redux setup or you want to make some changes to the Redux configuration, check out init's Redux configuration.
  • If you would like to develop a new plugin, see the Plugin API reference.

init([config])#

The function called to setup Rematch.

Arguments:

Init accepts one argument - config, which is an object with the following properties:

  • [name] (string): a name for your store. It might be useful when creating multiple stores. Default value is: "Rematch Store {counter}".

  • [models] (Object): each model describes its part of the state, reducers and effects. This parameter is a mapping from models' names to their configuration. See Model API for details.

  • [plugins] (Array): plugins are special sets of configuration that can extend the functionality of your store. You can pass an array of plugins that you want to use in your store. See the plugins developed by the Rematch team or the API for creating plugins.

  • [redux] (Object): there are situations where you might want to access Redux configuration directly, e.g. to migrate existing redux project or add middlewares. See Redux API for details.

Returns:

(Object) Fully configured Redux store with extra properties and methods supplied by Rematch. See Store API for details.

Example:

import { init } from '@rematch/core'
const store = init({
name: 'my custom store name',
models: {example1, example2},
plugins: [plugin1, plugin2],
redux: customReduxConfig,
})

For more comprehensive examples, visit examples.