Skip to content

hydrate

Will hydrate the client store with the provided initial state if one is provided.

Import

import { hydrate } from "@account-kit/core";

Usage

import { hydrate, cookieToInitialState } from "@account-kit/core";
import { config } from "./config";
 
const initialState = cookieToInitialState(document.cookie);
const { onMount } = hydrate(config, initialState);
// call onMount once your component has mounted

Parameters

config

AlchemyAccountsConfig the config containing the client store

initialState

StoredState optional param detailing the initial ClientState

Returns

{ onMount: () => Promise<void> } an object containing an onMount function that can be called when your component first renders on the client