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

# PersistStoreGate

If you want to use PersistStoreGate, first you have to wrap your application with `<PersistStoreGate eventrix={eventrix}>` component which obligatory need one prop - eventrix instance. Optionally, you can also add loader prop to show something during fetching data from external storage.

```jsx
const App = () => (
    <EventrixProvider eventrix={eventrix}>
        <PersistStoreGate eventrix={eventrix} loader={Loader}>
            <div className='app'>
                {...}
            </div>
        </PersistStoreGate>
    </EventrixProvider>
);

```

Next step is to use `connectPersistStore(eventrix, config)` function in file where you combine your whole application store. As you can see, this function needs two arguments. First one is eventrix instance and second one is config which is basically created from:\
\- storage (e.g. localStorage),\
\- storageKey (the key under which application state will be saved in provided storage),\
\- whiteList or blackList

```javascript
import { Eventrix, connectPersistStore } from 'eventrix';
import exampleReceiver from './receivers/example';

const initialState = {
    exampleCounterOne: 0,
    exampleCounterTwo: 0,
    exampleCounterThree: 0,
};

const eventsReceivers = [exampleReceiver];

const eventrix = new Eventrix(initialState, eventsReceivers);

const config = {
    storage: localStorage,
    storageKey: 'exampleData',
    whiteList: ['exampleCounterOne'], // or blackList: ['exampleCounterTwo', 'exampleCounterThree']
};

connectPersistStore(eventrix, config);

export default eventrix;
```

Let's say, I have three states in my application (`exampleCounterOne`, `exampleCounterTwo` and `exampleCounterThree`) and I want to save in external storage just one. In this case I can use `whiteList` which is array of strings. I only need to add name of state to array, like this `whiteList: ['exampleCounterOne']` .

Instead of `whiteList`, you can use `blackList` which is also array of strings but works different. Let's say, I would like to save all states from my store except one. In this case I can use blackList like that `blackList: ['exampleCounterTwo']`. It means that `exampleCounterOne` and `exampleCounterTwo` will be automatically saved to provided external storage.


---

# 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, and the optional `goal` query parameter:

```
GET https://eventrix.gitbook.io/eventrix/context/persiststoregate.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
