hydrate

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

Import

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

Usage

1import { hydrate, cookieToInitialState } from "@account-kit/core";
2import { config } from "./config";
3
4const initialState = cookieToInitialState(document.cookie);
5const { onMount } = hydrate(config, initialState);
6// 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