mirror of
https://github.com/hanzoai/billing.git
synced 2026-10-30 18:46:54 +00:00
wagmi and RainbowKit access indexedDB/localStorage at module load time, breaking Next.js static export prerendering. Split wallet providers into a separate module loaded via React.lazy with a mount guard so they only initialize in the browser.
25 lines
602 B
TypeScript
25 lines
602 B
TypeScript
'use client'
|
|
|
|
import * as React from 'react'
|
|
|
|
// Lazy-load wallet providers to avoid SSR issues (indexedDB/localStorage not available during static export)
|
|
const WalletProviders = React.lazy(() => import('./wallet-providers'))
|
|
|
|
export function Providers({ children }: { children: React.ReactNode }) {
|
|
const [mounted, setMounted] = React.useState(false)
|
|
|
|
React.useEffect(() => {
|
|
setMounted(true)
|
|
}, [])
|
|
|
|
if (!mounted) {
|
|
return <>{children}</>
|
|
}
|
|
|
|
return (
|
|
<React.Suspense fallback={<>{children}</>}>
|
|
<WalletProviders>{children}</WalletProviders>
|
|
</React.Suspense>
|
|
)
|
|
}
|