AurumProvider is 'use client'-marked and SSR-safe — getServerSnapshot returns the initializing state on the server, then the real connection state hydrates on the client. No special boundaries are needed.
Install
Requires React 18 or 19.
1. Create the Aurum instance
src/lib/aurum.ts
Aurum constructor is SSR-safe — it guards window and localStorage access internally — so this module imports cleanly on both server and client.
2. Wrap the root route
AurumProvider lives in the root route’s component, around the <Outlet />:
src/routes/__root.tsx
3. Build a connect button
Use the hooks anywhere in your route tree — no extra boundary needed.src/components/ConnectButton.tsx
isInitializing is true during SSR and during the brief client-side connection-restore. Always render a placeholder so the server-rendered HTML and the first client paint match.src/routes/index.tsx
4. Sign a message
src/components/SignMessageButton.tsx
Server-side caveats
- Route loaders and server functions cannot read wallet state. Loaders run on the server, where there is no wallet connection. Read the wallet client-side and pass any signed/derived data to server functions (e.g. via SIWE).
beforeLoadcannot gate routes by connection. Use a client-side guard component or readuseAccount()inside the route component instead.- Don’t construct multiple
Auruminstances per route. Keep onesrc/lib/aurum.tsimport everywhere.
Common patterns
Client-side route guard
src/components/RequireConnection.tsx
<RequireConnection>.
Sign-in with Ethereum (SIWE) for server functions
Server functions can verify a signed message to prove ownership of an address — sign it client-side with viem/ethers, then pass{ address, signature, message } to the server function for verification.
Next steps
Customization
Theme the modal
Headless mode
Build a fully custom UI
React Hooks
Hooks API reference