Skip to content

Commit

Permalink
(docs): add section on Node and SSR Usage
Browse files Browse the repository at this point in the history
- note that one can hydrate server-side with Node and give some example
  storage engines one may use for that purpose
- note that server-side hydartion can be skipped for certain use cases
  like SSR and give example for how to do so
  • Loading branch information
agilgur5 committed Jul 27, 2019
1 parent 506828c commit 16cc5b0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ persist('some', someStore, {

- returns a void Promise

### Node and Server-Side Rendering (SSR) Usage

Node environments are supported so long as you configure a Storage Engine that supports Node, such as [`redux-persist-node-storage`](https://github.com/pellejacobs/redux-persist-node-storage), [`redux-persist-cookie-storage`](https://github.com/abersager/redux-persist-cookie-storage), etc.
This allows you to hydrate your store server-side.

For SSR though, you may not want to hydrate your store server-side, so it is recommended that you only call `persist` conditionally:

```javascript
if (typeof window !== 'undefined') {
persist(...)
}
```

With this conditional check, your store will only be hydrated client-side.

## Examples

None yet, but can take a look at [agilgur5/react-native-manga-reader-app](https://github.com/agilgur5/react-native-manga-reader-app) which uses it in production.
Expand Down

0 comments on commit 16cc5b0

Please sign in to comment.