This guide covers Next.js with the App Router. Aurum is browser-only (Shadow DOM, localStorage, EIP-1193 events) so the integration centers around getting the 'use client' boundary right. A short Pages Router note is at the bottom.
Use NEXT_PUBLIC_* env vars — both project IDs are needed in the browser. Never put a server-only secret here.
The Aurum constructor is SSR-safe — it guards window / localStorage access internally — so importing this module from a Server Component will not throw. But the modal, hooks, and event listeners only run in the browser, so any component that uses Aurum must be a Client Component.
isInitializing is true while Aurum restores any persisted connection. Always render a placeholder — otherwise users see a flash of the disconnected state on every page load.
You can drop <ConnectButton /> into any Server Component page; the 'use client' boundary stays inside the component tree without infecting the rest of the page.
app/page.tsx
import { ConnectButton } from './components/ConnectButton';export default function Home() { return ( <main> <h1>Welcome</h1> <ConnectButton /> </main> );}
A few things that don’t work the way you might expect:
Server Components cannot use Aurum hooks. Wallet state lives in the browser. Read it from a Client Component and pass it down via context or props.
Middleware and Route Handlers cannot read wallet state. They run on the server, where there is no wallet connection. If you need server-side auth, sign a SIWE message client-side and verify it in a Route Handler.
Don’t dynamic-import Aurum with ssr: false unless you’re seeing a real hydration warning. The SDK is SSR-safe out of the box and ssr: false would defeat the persisted-connection restore on first paint.
Don’t construct multiple Aurum instances per route. The constructor returns the existing instance and warns if the new config differs. Keep one lib/aurum.ts import everywhere.