Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo/nextjs-ssr-app/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const metadata = {
description: "Web3Auth NextJS Quick Start",
};

export default function RootLayout({ children }: { children: React.ReactNode }) {
const web3authInitialState = cookieToWeb3AuthState((headers()).get('cookie'))
export default async function RootLayout({ children }: { children: React.ReactNode }) {
const web3authInitialState = cookieToWeb3AuthState(((await headers())).get('cookie'))
console.log("web3authInitialState", web3authInitialState)
return (
<html lang="en">
Expand Down
11 changes: 6 additions & 5 deletions demo/nextjs-ssr-app/components/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ import {
useWeb3AuthDisconnect,
useWeb3AuthUser,
} from "@web3auth/modal/react";
import { useAccount, useBalance, useChainId, useSignMessage, useSignTypedData, useSwitchChain } from "wagmi";
import { useConnection, useBalance, useChainId, useSignMessage, useSignTypedData, useSwitchChain, useChains } from "wagmi";

const Main = () => {
const { provider, isConnected } = useWeb3Auth();
const { chains, switchChain } = useSwitchChain();
const { mutate: switchChain } = useSwitchChain();
const chains = useChains();
const chainId = useChainId();
const { loading: connecting, connect, error: connectingError, connectorName } = useWeb3AuthConnect();
const { disconnect } = useWeb3AuthDisconnect();
const { signMessageAsync, data: signedMessageData } = useSignMessage();
const { address, isConnected: isWagmiConnected } = useAccount();
const { mutateAsync: signMessageAsync, data: signedMessageData } = useSignMessage();
const { address, isConnected: isWagmiConnected } = useConnection();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong hook used for account address and connection status

Medium Severity

The migration from useAccount to useConnection may be incorrect. According to wagmi documentation, useAccount is the hook for getting account information including address and isConnected. The useConnection hook has a different purpose and return type. The Vue demo uses { status, address } from useConnection (with status, not isConnected), suggesting the React code's attempt to destructure isConnected from useConnection may not work correctly, potentially causing the wagmi connection status to always appear disconnected.

Additional Locations (1)

Fix in Cursor Fix in Web

const { userInfo, isMFAEnabled } = useWeb3AuthUser();
const { data: balance } = useBalance({ address });
const { signTypedData, data: signedTypedDataData } = useSignTypedData();
const { mutate: signTypedData, data: signedTypedDataData } = useSignTypedData();
const { enableMFA, loading: isEnableMFALoading, error: enableMFAError } = useEnableMFA();
const { manageMFA, loading: isManageMFALoading, error: manageMFAError } = useManageMFA();
const { showCheckout, loading: isCheckoutLoading, error: checkoutError } = useCheckout();
Expand Down
11 changes: 11 additions & 0 deletions demo/nextjs-ssr-app/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig, globalIgnores } from "eslint/config";
import nextCoreWebVitals from "eslint-config-next/core-web-vitals";
import path from "node:path";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

export default defineConfig([globalIgnores(["**/*.config.js"]), {
extends: [...nextCoreWebVitals],
}]);
3 changes: 2 additions & 1 deletion demo/nextjs-ssr-app/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/dev/types/routes.d.ts";

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
Loading