diff --git a/demo/nextjs-ssr-app/app/layout.tsx b/demo/nextjs-ssr-app/app/layout.tsx index c4e238f59..189321d3c 100644 --- a/demo/nextjs-ssr-app/app/layout.tsx +++ b/demo/nextjs-ssr-app/app/layout.tsx @@ -5,7 +5,7 @@ import { Inter } from "next/font/google"; import Provider from "@/components/provider"; import { cookieToWeb3AuthState } from "@web3auth/modal"; import { headers } from "next/headers"; -import { cookieToInitialState } from "wagmi"; +import { cookieToWagmiState } from "@web3auth/modal/react/wagmi"; const inter = Inter({ subsets: ["latin"] }); @@ -16,11 +16,13 @@ export const metadata = { export default function RootLayout({ children }: { children: React.ReactNode }) { const web3authInitialState = cookieToWeb3AuthState((headers()).get('cookie')) - console.log("web3authInitialState", web3authInitialState) + const wagmiInitialState = cookieToWagmiState((headers()).get('cookie')) + console.log("web3authInitialState", web3authInitialState); + console.log("wagmiInitialState", wagmiInitialState); return ( - {children} + {children} ); diff --git a/demo/nextjs-ssr-app/components/Main.tsx b/demo/nextjs-ssr-app/components/Main.tsx index 67ccf4c43..68f45e9ca 100644 --- a/demo/nextjs-ssr-app/components/Main.tsx +++ b/demo/nextjs-ssr-app/components/Main.tsx @@ -12,7 +12,7 @@ import { useWeb3AuthDisconnect, useWeb3AuthUser, } from "@web3auth/modal/react"; -import { useAccount, useBalance, useSignMessage, useSignTypedData } from "wagmi"; +import { useAccount, useBalance, useChainId, useSignMessage, useSignTypedData, useSwitchChain } from "wagmi"; const Main = () => { const { provider, isConnected } = useWeb3Auth(); @@ -29,16 +29,19 @@ const Main = () => { const { showWalletConnectScanner, loading: isWalletConnectScannerLoading, error: walletConnectScannerError } = useWalletConnectScanner(); const { showWalletUI, loading: isWalletUILoading, error: walletUIError } = useWalletUI(); const { token, loading: isUserTokenLoading, error: userTokenError, authenticateUser } = useIdentityToken(); - + const { switchChainAsync, chains } = useSwitchChain(); + const chainId = useChainId(); + console.log("isConnected", isConnected); - + console.log("isWagmiConnected", isWagmiConnected); const loggedInView = ( <>
- {/*

Account Address: {address}

*/} - {/*

Account Balance: {balance?.value}

*/} +

Account Address: {address}

+

Account Balance: {balance?.formatted}

MFA Enabled: {isMFAEnabled ? "Yes" : "No"}

+

ConnectedChain ID: {chainId}

{/* User Info */} @@ -177,6 +180,22 @@ const Main = () => { {signedTypedDataData &&