Skip to content

Commit f4234c5

Browse files
authored
Updating Create React App to NextJs in Base Account Docs (#332)
* updating react guide to next * update next app
1 parent 469beae commit f4234c5

1 file changed

Lines changed: 45 additions & 17 deletions

File tree

docs/base-account/quickstart/web-react.mdx

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
11
---
2-
title: "Web (React)"
3-
description: "This quick-start shows the minimum code required to add Sign in with Base and Base Pay to any React app using the Base Account SDK."
2+
title: "Web (Next.js)"
3+
description: "Quickly add Sign in with Base and Base Pay to any Next.js app"
44
---
55

66
import { GithubRepoCard } from "/snippets/GithubRepoCard.mdx"
77

8-
This quick-start shows the **minimum** code required to add Sign in with Base and Base Pay to any React app using the Base Account SDK.
8+
This quick-start shows the **minimum** code required to add Sign in with Base (SIWB) and Base Pay to any Next.js app using the Base Account SDK.
99

10-
## 1. Create a new React app
10+
## 1. Create a new Next.js app
1111

12-
If you're starting fresh, create a new React app:
12+
If you're starting fresh, create a new Next.js app:
1313

1414
<CodeGroup>
1515
```bash npm
16-
npx create-react-app base-account-quickstart
16+
npx create-next-app@latest base-account-quickstart
1717
cd base-account-quickstart
1818
```
1919

2020
```bash yarn
21-
yarn create react-app base-account-quickstart
21+
yarn create next-app base-account-quickstart
22+
cd base-account-quickstart
23+
```
24+
25+
```bash pnpm
26+
pnpm create next-app base-account-quickstart
27+
cd base-account-quickstart
28+
```
29+
30+
```bash bun
31+
bunx create-next-app base-account-quickstart
2232
cd base-account-quickstart
2333
```
2434
</CodeGroup>
2535

36+
When prompted during setup, you can choose the default options or customize as needed. For this quickstart, the default settings work perfectly.
37+
2638
## 2. Install the SDK
2739

2840
<CodeGroup>
@@ -49,14 +61,18 @@ bun add @base-org/account @base-org/account-ui
4961
Use `--legacy-peer-deps` flag if you get a peer dependency error.
5062
</Tip>
5163

52-
## 3. Replace src/App.js with this component
64+
## 3. Create the main component
65+
66+
Replace the contents of `app/page.tsx` (or `app/page.js` if not using TypeScript) with this component:
67+
68+
```jsx title="app/page.tsx" lineNumbers
69+
'use client';
5370

54-
```jsx title="src/App.js" lineNumbers
5571
import React, { useState } from 'react';
5672
import { createBaseAccountSDK, pay, getPaymentStatus } from '@base-org/account';
5773
import { SignInWithBaseButton, BasePayButton } from '@base-org/account-ui/react';
5874

59-
function App() {
75+
export default function Home() {
6076
const [isSignedIn, setIsSignedIn] = useState(false);
6177
const [paymentStatus, setPaymentStatus] = useState('');
6278
const [paymentId, setPaymentId] = useState('');
@@ -186,8 +202,6 @@ function App() {
186202
</div>
187203
);
188204
}
189-
190-
export default App;
191205
```
192206

193207
<Note>
@@ -196,18 +210,32 @@ export default App;
196210
Make sure to replace `0xRecipientAddress` with your recipient address.
197211
</Note>
198212

213+
<Tip>
214+
**Base Pay and SIWB are independent**
215+
216+
You DO NOT need to use SIWB to use Base Pay. You can just call the `pay()` function without any additional setup.
217+
</Tip>
218+
199219
## 4. Start your app
200220

201221
```bash
202-
npm start
222+
npm run dev
203223
```
204224

205225
Open http://localhost:3000, click **Sign in with Base** (optional) and then **Pay**, approve the transaction, and you've sent 5 USDC on Base Sepolia—done! 🎉
206226

207-
**Note:** If you have an existing React app, just install the SDK (`npm install @base-org/account`) and add the component above to your project.
227+
**Note:** If you have an existing Next.js app, just install the SDK (`npm install @base-org/account @base-org/account-ui`) and add the component above to your project. For other React frameworks, you can adapt this component as needed.
208228

209229
## Next steps
210230

211-
* **[Request profile data](/base-account/guides/accept-payments#collect-user-information-optional)** – ask the user for email, shipping address, etc. during `pay()`
212-
* **[Sub Accounts guide](/base-account/improve-ux/sub-accounts)** – embed gas-less child wallets inside your app
213-
* **[Mobile quick-start](/base-account/quickstart/mobile-integration)** – the same flow for React Native
231+
* **[Authenticate Users](/base-account/guides/authenticate-users)** strong authentication by setting up Sign in with Base with backend verification
232+
* **[Accept Payments](/base-account/guides/accept-payments)** explore all the features of Base Pay
233+
* **[Sign in with Base Button](/base-account/reference/ui-elements/sign-in-with-base-button)** – implement full SIWE authentication with backend verification
234+
* **[Base Pay Button](/base-account/reference/ui-elements/base-pay-button)** – collect user information during payment flow
235+
236+
<Warning>
237+
**Please Follow the Brand Guidelines**
238+
239+
If you intend on using the `SignInWithBaseButton` or `BasePayButton`, please follow the [Brand Guidelines](/base-account/reference/ui-elements/brand-guidelines) to ensure consistency across your application.
240+
241+
</Warning>

0 commit comments

Comments
 (0)