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 a36a41b commit 2403d6e
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 @@ -65,6 +65,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 in that case you can call `persist` conditionally:

```javascript
if (typeof window !== 'undefined') { // window is undefined in Node
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 2403d6e

Please sign in to comment.