Skip to content

Commit 93b9a76

Browse files
committed
Update nextjs quick start
1 parent 440c143 commit 93b9a76

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

quick-starts/nextjs-quick-start/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import React from "react";
4-
import App from "../components/App";
4+
import App from "../components/app";
55

66
export default function Home() {
77
return <App />;

quick-starts/nextjs-quick-start/components/App.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1+
// IMP START - Quick Start
12
import { useWeb3AuthConnect, useWeb3AuthDisconnect, useWeb3AuthUser } from "@web3auth/modal/react";
3+
// IMP END - Quick Start
4+
// IMP START - Blockchain Calls
25
import { useAccount } from "wagmi";
36
import { SendTransaction } from "./wagmi.tsx/sendTransaction";
47
import { Balance } from "./wagmi.tsx/getBalance";
58
import { SwitchChain } from "./wagmi.tsx/switchNetwork";
9+
// IMP END - Blockchain Calls
10+
611
function App() {
12+
// IMP START - Login
713
const { connect, isConnected, loading: connectLoading, error: connectError } = useWeb3AuthConnect();
14+
// IMP END - Login
15+
// IMP START - Logout
816
const { disconnect, loading: disconnectLoading, error: disconnectError } = useWeb3AuthDisconnect();
17+
// IMP END - Logout
918
const { userInfo } = useWeb3AuthUser();
19+
// IMP START - Blockchain Calls
1020
const { address, connector } = useAccount();
21+
// IMP END - Blockchain Calls
1122

1223
function uiConsole(...args: any[]): void {
1324
const el = document.querySelector("#console>p");
@@ -20,35 +31,43 @@ function App() {
2031
const loggedInView = (
2132
<div className="grid">
2233
<h2>Connected to {connector?.name}</h2>
34+
{/* IMP START - Blockchain Calls */}
2335
<div>{address}</div>
36+
{/* IMP END - Blockchain Calls */}
2437
<div className="flex-container">
2538
<div>
2639
<button onClick={() => uiConsole(userInfo)} className="card">
2740
Get User Info
2841
</button>
2942
</div>
43+
{/* IMP START - Logout */}
3044
<div>
3145
<button onClick={() => disconnect()} className="card">
3246
Log Out
3347
</button>
3448
{disconnectLoading && <div className="loading">Disconnecting...</div>}
3549
{disconnectError && <div className="error">{disconnectError.message}</div>}
3650
</div>
51+
{/* IMP END - Logout */}
3752
</div>
53+
{/* IMP START - Blockchain Calls */}
3854
<SendTransaction />
3955
<Balance />
4056
<SwitchChain />
57+
{/* IMP END - Blockchain Calls */}
4158
</div>
4259
);
4360

4461
const unloggedInView = (
62+
// IMP START - Login
4563
<div className="grid">
4664
<button onClick={() => connect()} className="card">
4765
Login
4866
</button>
4967
{connectLoading && <div className="loading">Connecting...</div>}
5068
{connectError && <div className="error">{connectError.message}</div>}
5169
</div>
70+
// IMP END - Login
5271
);
5372

5473
return (

quick-starts/nextjs-quick-start/components/provider.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
1212
// IMP START - Dashboard Registration
1313
const clientId = process.env.NEXT_PUBLIC_WEB3AUTH_CLIENT_ID || ""; // get from https://dashboard.web3auth.io
1414
// IMP END - Dashboard Registration
15-
const queryClient = new QueryClient();
1615

17-
// IMP START - Instantiate SDK
16+
// IMP START - Setup Wagmi Provider
17+
const queryClient = new QueryClient();
18+
// IMP END - Setup Wagmi Provider
19+
20+
// IMP START - Config
1821
const web3AuthContextConfig: Web3AuthContextConfig = {
1922
web3AuthOptions: {
2023
clientId,
2124
web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
2225
authBuildEnv: "testing",
2326
}
2427
};
25-
// IMP END - Instantiate SDK
28+
// IMP END - Config
2629

2730
export default function Provider({ children }: { children: React.ReactNode }) {
2831
return (

quick-starts/react-quick-start/src/App.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import "./App.css";
2+
// IMP START - Quick Start
23
import { useWeb3AuthConnect, useWeb3AuthDisconnect, useWeb3AuthUser } from "@web3auth/modal/react";
4+
// IMP END - Quick Start
5+
36
// IMP START - Blockchain Calls
47
import { useAccount } from "wagmi";
58
import { SendTransaction } from "./components/sendTransaction";
@@ -48,9 +51,11 @@ function App() {
4851
</div>
4952
{/* // IMP END - Logout */}
5053
</div>
54+
{/* IMP START - Blockchain Calls */}
5155
<SendTransaction />
5256
<Balance />
5357
<SwitchChain />
58+
{/* IMP END - Blockchain Calls */}
5459
</div>
5560
);
5661

quick-starts/react-quick-start/src/web3authContext.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// IMP START - Quick Start
21
import { WEB3AUTH_NETWORK } from "@web3auth/modal";
32
import { type Web3AuthContextConfig } from "@web3auth/modal/react";
4-
// IMP END - Quick Start
53

64
// IMP START - Dashboard Registration
75
const clientId = import.meta.env.VITE_WEB3AUTH_CLIENT_ID || ""; // get from https://dashboard.web3auth.io

0 commit comments

Comments
 (0)