Definisi
Cookie storage
Adapter storan wagmi yang menyimpan keadaan dompet ke dalam kuki untuk SSR.
Cookie storage
A wagmi storage adapter that persists wallet state to cookies for SSR.
In context
On PolyArb we use cookie storage so wallet state survives server-side rendering. When a user connects a wallet via a connector such as MetaMask or a Gnosis Safe, wagmi normally keeps session state in client-side storage. A cookie storage adapter mirrors the minimal wallet state (for example, the active connector and address) into HTTP cookies so the server-rendered pages can read and render account-aware UI during initial page load. This improves perceived performance and avoids a flash of disconnected UI when your app hydrates.
How it works (high level)
- During a client session wagmi writes select keys to the cookie storage adapter instead of, or in addition to, localStorage.
- Server-side rendering code can read those cookies and determine whether to render logged-in components, masked balances, or connector-specific UI.
- Cookies should store only non-sensitive, minimal state (connector id, truncated address). Private keys and approval signatures must never be stored in cookies.
Implementation notes
- Cookie storage is an adapter pattern for wagmi; the exact API depends on the wagmi version and your framework (Next.js, Remix, etc.). Use secure, httpOnly (when appropriate), SameSite and path attributes consistent with your app's security model.
- Because Polymarket/PolyArb use Polygon and pUSD, wallet state here is purely UX state; actual signing and on-chain operations still occur client-side through the wallet connector.
- Respect Polymarket's geo restrictions and never try to bypass them via cookie tricks. Don't store KYC-sensitive data in cookies.
See also
- /glossary/CLOB
- /glossary/Relayer
- /glossary/pUSD