Skip to content

Commit bbd25ce

Browse files
Document using SDK CLI (#2010)
* Document using SDK CLI * update what's new
1 parent b3235c6 commit bbd25ce

File tree

6 files changed

+170
-29
lines changed

6 files changed

+170
-29
lines changed

docs/whats-new.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ of the [MetaMask developer page](https://metamask.io/developer/).
1111

1212
## May 2025
1313

14+
- Documented how to use the SDK CLI to set up a [JavaScript + Wagmi](/sdk/quickstart/javascript-wagmi) or [Dynamic SDK](/sdk/quickstart/javascript-dynamic) project.
15+
([#2010](https://github.com/MetaMask/metamask-docs/pull/2010))
1416
- Documented [how to send batch transactions via EIP-5792 and EIP-7702](/wallet/how-to/send-transactions/send-batch-transactions).
1517
([#1946](https://github.com/MetaMask/metamask-docs/pull/1946))
1618
- Documented Infura's filter API method support for [Arbitrum](/services/reference/arbitrum/json-rpc-methods/filter-methods/),

sdk/_assets/quickstart-dynamic.png

1.09 MB
Loading

sdk/guides/authenticate-users.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ With the SDK, you can:
1717
- **Support multiple wallet types** (extension, mobile app).
1818

1919
<p align="center">
20-
<a href="https://metamask-sdk-examples-relink.vercel.app/" target="_blank">
20+
<a href="https://metamask-sdk-examples.vercel.app/" target="_blank">
2121
<img src={require("../_assets/connect.gif").default} alt="Connect to MetaMask" width="450px" />
2222
</a>
2323
</p>

sdk/guides/manage-networks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ With the SDK, you can:
1414
- **Handle common network-related errors**.
1515

1616
<p align="center">
17-
<a href="https://metamask-sdk-examples-relink.vercel.app/" target="_blank">
17+
<a href="https://metamask-sdk-examples.vercel.app/" target="_blank">
1818
<img src={require("../_assets/network.gif").default} alt="Switch Networks" width="450px" />
1919
</a>
2020
</p>

sdk/quickstart/javascript-dynamic.md

Lines changed: 90 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@ toc_max_heading_level: 2
77
# MetaMask SDK + Dynamic SDK integration
88

99
Get started with MetaMask SDK and [Dynamic SDK](https://docs.dynamic.xyz/introduction/welcome).
10-
You can [use the quickstart template](#set-up-using-a-template), which automatically sets up both SDKs with a [Next.js](https://nextjs.org/docs) and [Wagmi](https://wagmi.sh/) dapp.
11-
You can also [manually set up the SDK](#set-up-manually) in an existing dapp.
10+
You can set up the SDKs in the following ways:
11+
12+
- [SDK CLI](#set-up-using-the-cli) - Use the CLI to scaffold a Next.js and Wagmi dapp with both SDKs.
13+
- [Quickstart template](#set-up-using-a-template) - Clone the template to set up a Next.js and Wagmi dapp with both SDKs.
14+
- [Manual setup](#set-up-manually) - Set up both SDKs in an existing dapp.
15+
16+
<p align="center">
17+
<img src={require("../_assets/quickstart-dynamic.png").default} alt="Dynamic SDK Quickstart" width="450px" />
18+
</p>
1219

1320
Features include:
1421

@@ -18,11 +25,10 @@ Features include:
1825
- **TypeScript support** - Full type safety and modern development experience.
1926
- **Next.js integration** - Built with Next.js 14 and App Router.
2027

21-
## Project structure
22-
28+
:::note Project structure
2329
The project you will set up has the following structure:
2430

25-
```
31+
```text
2632
├── app/
2733
│ ├── providers.tsx # Main providers configuration
2834
│ └── layout.tsx # Root layout with providers
@@ -33,6 +39,68 @@ The project you will set up has the following structure:
3339
├── next.config.ts # Next.js configuration
3440
└── package.json # Project dependencies
3541
```
42+
:::
43+
44+
## Prerequisites
45+
46+
- [Node.js](https://nodejs.org/) version 19 or later
47+
- [pnpm](https://pnpm.io/installation)
48+
- [MetaMask](https://metamask.io/) installed in your browser or on mobile
49+
- A [Dynamic Environment ID](https://app.dynamic.xyz/)
50+
51+
## Set up using the CLI
52+
53+
1. Run the CLI command, replacing `<project-name>` with your project name:
54+
55+
```bash
56+
npx @consensys/create-web3-app <project-name>
57+
```
58+
59+
2. Select the Dynamic Quickstart template:
60+
61+
```bash
62+
? Please select the template you want to use:
63+
Next.js Quickstart (MetaMask SDK Example) (Recommended)
64+
❯ MetaMask <-> Dynamic Quickstart
65+
```
66+
67+
3. Select your preferred blockchain tooling if your project requires it:
68+
69+
```bash
70+
? Would you like to include blockchain tooling? (Use arrow keys)
71+
❯ HardHat
72+
Foundry
73+
None
74+
```
75+
76+
4. Select your preferred package manager.
77+
We recommend pnpm for speed and efficiency:
78+
79+
```bash
80+
? Please select the package manager you want to use:
81+
Yarn
82+
NPM
83+
❯ pnpm
84+
```
85+
86+
5. Select to enter your Dynamic Environment ID in the command prompt:
87+
88+
```bash
89+
? The selected template uses Dynamic.xyz. You'll need a Dynamic Environment ID
90+
added to a .env file. Would you like to add it now? You can get one from
91+
https://app.dynamic.xyz/dashboard/developer/api Yes
92+
? Please paste your Dynamic Environment ID:
93+
```
94+
95+
5. The CLI will take a few minutes to set up your project.
96+
Once complete, you can run the project using the following command in `<project-name>/packages/site`:
97+
98+
```bash
99+
pnpm run dev
100+
```
101+
102+
You've successfully set up MetaMask SDK and Dynamic SDK.
103+
See how to [use the combined SDKs](#usage).
36104
37105
## Set up using a template
38106
@@ -54,6 +122,18 @@ The project you will set up has the following structure:
54122
pnpm install
55123
```
56124
125+
4. Create a `.env.local` file:
126+
127+
```bash
128+
touch .env.local
129+
```
130+
131+
5. In `.env.local`, add a `NEXT_PUBLIC_DYNAMIC_ENVIRONMENT_ID` environment variable, replacing `<YOUR-ENVIRONMENT-ID>` with your Dynamic Environment ID:
132+
133+
```text title=".env.local"
134+
NEXT_PUBLIC_DYNAMIC_ENVIRONMENT_ID=<YOUR-ENVIRONMENT-ID>
135+
```
136+
57137
4. Run the project:
58138
59139
```bash
@@ -130,12 +210,15 @@ export function Providers({ children }: { children: React.ReactNode }) {
130210
131211
### 3. Set up environment variables
132212
133-
Create a `.env.local` file:
213+
Create a `.env.local` file.
214+
In `.env.local`, add a `NEXT_PUBLIC_DYNAMIC_ENVIRONMENT_ID` environment variable, replacing `<YOUR-ENVIRONMENT-ID>` with your Dynamic Environment ID:
134215
135216
```text title=".env.local"
136-
NEXT_PUBLIC_DYNAMIC_ENVIRONMENT_ID=your_dynamic_environment_id
217+
NEXT_PUBLIC_DYNAMIC_ENVIRONMENT_ID=<YOUR-ENVIRONMENT-ID>
137218
```
138219
220+
You can now test your dapp by running `pnpm run dev`.
221+
139222
## Usage
140223
141224
### Connect wallet

sdk/quickstart/javascript-wagmi.md

Lines changed: 76 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ toc_max_heading_level: 2
66
# JavaScript + Wagmi (recommended)
77

88
Get started with MetaMask SDK in a JavaScript and Wagmi dapp.
9-
You can [use the quickstart template](#set-up-using-a-template), which automatically sets up
10-
the SDK with a [Next.js](https://nextjs.org/) and [Wagmi](https://wagmi.sh/) dapp.
11-
You can also [manually set up the SDK](#set-up-manually) in an existing dapp.
9+
You can set up the SDK in the following ways:
10+
11+
- [SDK CLI](#set-up-using-the-cli) - Use the CLI to scaffold a Next.js and Wagmi dapp.
12+
- [Quickstart template](#set-up-using-a-template) - Clone the template to set up a Next.js and Wagmi dapp.
13+
- [Manual setup](#set-up-manually) - Set up the SDK in an existing dapp.
14+
15+
<p align="center">
16+
<a href="https://metamask-sdk-examples.vercel.app/" target="_blank">
17+
<img src={require("../_assets/quickstart.jpg").default} alt="Quickstart" width="450px" />
18+
</a>
19+
</p>
1220

1321
Features include:
1422

@@ -17,11 +25,69 @@ Features include:
1725
- **Interactive UI** - Responsive design with interactive cards guiding users.
1826
- **Modular components** - Easy-to-understand and customizable components.
1927

20-
<p align="center">
21-
<a href="https://metamask-sdk-examples-relink.vercel.app/" target="_blank">
22-
<img src={require("../_assets/quickstart.jpg").default} alt="Quickstart" width="450px" />
23-
</a>
24-
</p>
28+
:::note Project structure
29+
The project you will set up has the following structure:
30+
31+
```text
32+
├── app/
33+
│ ├── providers.tsx # Main providers configuration
34+
│ └── layout.tsx # Root layout with providers
35+
├── components/
36+
│ ├── Navbar.tsx # Navigation with wallet connection
37+
│ └── Hero.tsx # Hero section with wallet status
38+
├── wagmi.config.ts # Wagmi configuration
39+
├── next.config.ts # Next.js configuration
40+
└── package.json # Project dependencies
41+
```
42+
:::
43+
44+
## Prerequisites
45+
46+
- [Node.js](https://nodejs.org/) version 19 or later
47+
- [pnpm](https://pnpm.io/installation)
48+
- [MetaMask](https://metamask.io/) installed in your browser or on mobile
49+
50+
## Set up using the CLI
51+
52+
1. Run the CLI command, replacing `<project-name>` with your project name:
53+
54+
```bash
55+
npx @consensys/create-web3-app <project-name>
56+
```
57+
58+
2. Select the Next.js Quickstart template:
59+
60+
```bash
61+
? Please select the template you want to use:
62+
❯ Next.js Quickstart (MetaMask SDK Example) (Recommended)
63+
MetaMask <-> Dynamic Quickstart
64+
```
65+
66+
3. Select your preferred blockchain tooling if your project requires it:
67+
68+
```bash
69+
? Would you like to include blockchain tooling? (Use arrow keys)
70+
❯ HardHat
71+
Foundry
72+
None
73+
```
74+
75+
4. Select your preferred package manager.
76+
We recommend pnpm for speed and efficiency:
77+
78+
```bash
79+
? Please select the package manager you want to use:
80+
Yarn
81+
NPM
82+
❯ pnpm
83+
```
84+
85+
5. The CLI will take a few minutes to set up your project.
86+
Once complete, you can run the project using the following command in `<project-name>/packages/site`:
87+
88+
```bash
89+
pnpm run dev
90+
```
2591
2692
## Set up using a template
2793
@@ -50,9 +116,6 @@ Features include:
50116
pnpm dev
51117
```
52118
53-
You've successfully set up MetaMask SDK with Wagmi.
54-
You can now [add your own functionality](#add-your-own-functionality).
55-
56119
## Set up manually
57120
58121
### 1. Install the SDK
@@ -138,9 +201,7 @@ export const ConnectButton = () => {
138201
}
139202
```
140203
141-
Once you've added the connect button, you can test your dapp by running `npm run dev` or `pnpm run dev` or `yarn dev`.
142-
It should work with the [MetaMask browser extension](https://metamask.io/download/) installed
143-
or [MetaMask Mobile](https://metamask.io/download/).
204+
Once you've added the connect button, you can test your dapp by running `pnpm run dev`.
144205
145206
## Production readiness
146207
@@ -163,16 +224,11 @@ const config = createConfig({
163224
164225
Sign up to [MetaMask Developer](https://developer.metamask.io/) for a free account and get your API key.
165226
166-
## Add your own functionality
227+
## Next steps
167228
168229
After completing the basic setup, you can follow these guides to add your own functionality:
169230
170231
- [Authenticate users](../guides/authenticate-users.md)
171232
- [Manage networks](../guides/manage-networks.md)
172233
- [Handle transactions](../guides/handle-transactions.md)
173234
- [Interact with smart contracts](../guides/interact-with-contracts.md)
174-
175-
## More examples
176-
177-
See the [`metamask-sdk-examples`](https://github.com/metamask/metamask-sdk-examples) GitHub
178-
repository for more examples.

0 commit comments

Comments
 (0)