> For the complete documentation index, see [llms.txt](https://rematch.gitbook.io/handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rematch.gitbook.io/handbook/cha-jian/rematch-persist.md).

# Rematch Persist

使用 local  storage 选项提供简单的 redux 状态持久化。

![](/files/-LDMDLT0sy1TfQPGEaUR)

### 安装

```bash
npm install @rematch/persist
```

> 针对   @rematch/core\@0.x 使用  @rematch/persist\@0.2.1

### 设置

```javascript
import createRematchPersist from '@rematch/persist'

const persistPlugin = createRematchPersist({
  whitelist: ['modelName1'],
  throttle: 5000,
  version: 1,
})

init({
  plugins: [persistPlugin]
})
```

### Persist Gate

和React一起使用，在等待数据从 storage 中异步加载的同时显示 loading 指示器。

```javascript
import { getPersistor } from '@rematch/persist'
import { PersistGate } from 'redux-persist/es/integration/react'

const persistor = getPersistor()

const Root = () => {
  <PersistGate persistor={persistor}>
    <App />
  </PersistGate>
}
```

### 配置选项

参看  [redux-persist config docs](https://github.com/rt2zz/redux-persist/blob/master/docs/api.md#type-persistconfig)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rematch.gitbook.io/handbook/cha-jian/rematch-persist.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
