> For the complete documentation index, see [llms.txt](https://overmindjs.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overmindjs.org/v27/api-1/rehydrate.md).

# rehydrate

It is possible to update the complete state of Overmind using the **rehydrate** tool. It allows you to update the state either with a state object or an array of mutations, typically collected from server side rendering.

{% tabs %}
{% tab title="overmind/onInitialize.ts" %}

```typescript
import { rehydrate } from 'overmind'

export const onInitialize = ({ state, effects }) => {
  // Grab mutations from a server rendered version
  const mutations = window.__OVERMIND_MUTATIONS

  rehydrate(state, mutations)

  // Grab a previous copy of the state, for example stored in
  // localstorage
  rehydrate(state, effects.storage.get('previousState') || {})
}
```

{% endtab %}
{% endtabs %}

The function takes into acount the state structure of Overmind which is based on objects where functions are derived state. That means it will leave derived state alone, resulting in them rather updating if any of their dependecies where updated by rehydration.


---

# 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://overmindjs.org/v27/api-1/rehydrate.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.
