cookieToInitialState
Helper to convert a cookie string into initial state.
Import
ts
import { cookieToInitialState } from '@wagmi/core'
Usage
ts
import { cookieToInitialState } from '@wagmi/core'
import config from './config'
function handler(req: Request) {
const initialState = cookieToInitialState(config, req.headers.cookie)
// ...
}
ts
import {
createConfig,
http,
cookieStorage,
createStorage
} from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
ssr: true,
storage: createStorage({
storage: cookieStorage,
}),
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
Parameters
config
Config
Wagmi Config
cookie
string | null | undefined
The cookie string.
Return Type
State
Initial state.