Skip to content

Commit 2284ea7

Browse files
authored
Update best practices and SIWF info for mini apps in Base App (#116)
* update mini app best practices and add new Base App name * add wagmi and window.ethereum guides for wallet interactions
1 parent 4739165 commit 2284ea7

File tree

3 files changed

+134
-50
lines changed

3 files changed

+134
-50
lines changed

docs/cookbook/onchain-social.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ Building successful Mini Apps requires understanding social-specific patterns an
350350
Optimize loading times and user experience for mobile social environments
351351
</Card>
352352
<Card title="Coinbase Wallet Integration" icon="wallet" href="/wallet-app/introduction/mini-apps">
353-
Specific guidance for optimizing Mini Apps in Coinbase Wallet
353+
Specific guidance for optimizing Mini Apps in Base App
354354
</Card>
355355
</CardGroup>
356356

docs/wallet-app/introduction/getting-started.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
title: Getting Started with Mini Apps
3-
description: Overview and implementation guide for Mini Apps in Coinbase Wallet
3+
description: Overview and implementation guide for Mini Apps in Base App
44
---
55

66

77

8-
Mini Apps are lightweight web applications that run natively within clients like Coinbase Wallet. Users instantly access mini apps without downloads, benefit from seamless wallet interactions, and discover apps directly in the social feed. This benefits app developers by creating viral loops for user acquisition and engagement.
8+
Mini Apps are lightweight web applications that run natively within clients like Base App. Users instantly access mini apps without downloads, benefit from seamless wallet interactions, and discover apps directly in the social feed. This benefits app developers by creating viral loops for user acquisition and engagement.
99

1010
## What is a Mini App?
1111

docs/wallet-app/introduction/mini-apps.mdx

Lines changed: 131 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,52 @@
11
---
2-
title: Mini Apps in Coinbase Wallet
3-
description: Guide for building and optimizing mini apps for Coinbase Wallet
2+
title: Mini Apps in Base App
3+
description: Guide for building and optimizing mini apps for Base App
44
---
55

66

7-
We're so excited that mini apps are coming to Coinbase Wallet! The purpose of this guide is to go over how to build or update your mini app so it works as well as possible in Coinbase Wallet.
7+
We're so excited that mini apps are supported in Base App! The purpose of this guide is to go over how to build or update your mini app so it works as well as possible in Base App.
88

99
## Using MiniKit
1010

11+
For reference, MiniKit is easiest way to build mini apps on Base, allowing developers to easily build mini apps without needing to know the details of the SDK implementation. It integrates seamlessly with OnchainKit components and provides Base App-specific hooks.
12+
1113
<Card title="Quick Start with MiniKit" icon="rocket" href="/wallet-app/build-with-minikit/quickstart">
12-
If you use MiniKit and/or follow the MiniKit quickstart guide, your mini app will work out of the box in Coinbase Wallet!
14+
If you use MiniKit and/or follow the MiniKit quickstart guide, your mini app will work out of the box in Base App!
1315
</Card>
1416

15-
For reference, MiniKit is easiest way to build mini apps on Base, allowing developers to easily build mini apps without needing to know the details of the SDK implementation. It integrates seamlessly with OnchainKit components and provides Coinbase Wallet-specific hooks.
16-
1717
<Card title="Debugging Guide" icon="bug" href="/wallet-app/build-with-minikit/debugging">
1818
If you're already using MiniKit and experiencing issues, you can refer to our debugging guide
1919
</Card>
2020

2121
## Authentication
2222

2323
<Warning>
24-
As a general rule of thumb for building any mini app, we recommend that you do not automatically request that the user logs in/signs a message and instead that authentication is only used when it's needed (e.g. signing up for an event, viewing authenticated resources, etc).
24+
As a general rule of thumb, we recommend that you save authentication that requires an interaction for interactions that require it(eg. buying something, viewing personalized pages etc)
2525
</Warning>
2626

27-
Below we will quickly cover the different methods of authentication offered for mini apps and how well each of them work in Coinbase Wallet:
27+
Below we will quickly cover the different methods of authentication offered for mini apps and how well each of them work in Base App:
2828

2929
<Tabs>
30-
<Tab title="Wallet Authentication (Recommended)">
31-
Because users in Coinbase Wallet have an in-app smart wallet that doesn't require any app switching, we recommend wallet authentication as the primary method of authentication for developers looking to create a persisted session for the mini app user.
30+
<Tab title="Sign In with Farcaster/Quick Auth">
31+
Base App natively supports [Sign In with Farcaster](https://github.com/farcasterxyz/protocol/discussions/110)(SIWF) in-app, so you can sign users in and get their social identity all without leaving Base App.
32+
33+
We also support [Quick Auth](https://miniapps.farcaster.xyz/docs/sdk/quick-auth), which uses Sign In with Farcaster to issue developers a [JWT](https://jwt.io/introduction) that can be used to persist the user's session in the mini app.
34+
35+
This is the expected flow for end-users to Sign In with Farcaster in your mini app:
36+
- **Create Account Users**: Users who created a net-new Farcaster account during Base App onboarding
37+
- When signing into a mini app, the user will be prompted to see a "Login request" tray showing the SIWF message and can sign it right their with their passkey
38+
- **Connect Account Users**: Users who connected an existing Farcaster account during Base App onboarding
39+
- When signing into a mini app for the first time, the user will be prompted to deeplink to Farcaster(one-time only) and register their wallet as an auth address, which will then enable seamless in-app sign in -- just like the above create account flow
40+
</Tab>
41+
42+
<Tab title="Wallet Auth">
43+
Because users in Base App have an in-app smart wallet that doesn't require any app switching, we recommend wallet authentication as the primary method of authentication for developers looking to create a persisted session for the mini app user.
3244

3345
As described below, we don't think it's the best practice to prompt the user to log in before that authentication will allow them to do something else in your mini app, but for cases where do you want a secure, persisted session, using a wallet connection is a great option.
3446
</Tab>
3547

3648
<Tab title="Context Data">
37-
All mini app host apps (including Coinbase Wallet) return [context data](https://miniapps.farcaster.xyz/docs/sdk/context), which tells developers about the app/mini app host the user is accessing their mini app in, as well as **which user** is interacting with their mini app.
49+
All mini app host apps (including Base App) return [context data](https://miniapps.farcaster.xyz/docs/sdk/context), which tells developers about the app/mini app host the user is accessing their mini app in, as well as **which user** is interacting with their mini app.
3850

3951
A common flow that other mini app developers follow is using the context data to either track analytics metrics or create an authentication session via a [JWT](https://jwt.io/introduction). This allows you to still track analytics/offer certain authenticated services to your users without the extra friction of signing a message or deeplinking to another app.
4052

@@ -43,34 +55,23 @@ Something important to note is that because of how the current mini app spec is
4355
</Warning>
4456
</Tab>
4557

46-
<Tab title="Sign In with Farcaster">
47-
Currently, using Sign In with Farcaster inside of Coinbase Wallet is **not recommended as the primary method of authentication**. This is because, for Farcaster accounts that were created in Farcaster (which many current accounts were), using Sign In with Farcaster will require deeplinking the user to Farcaster and then back to Coinbase Wallet. While this flow still works inside of Coinbase Wallet, we recommend either wallet auth or creating an auth strategy around the context data (eg. a custom JWT with context data) for a more optimal UX.
48-
49-
<Info>
50-
Note: The Sign In with Farcaster flow will no longer require a deeplink to Farcaster when the [auth addresses FIP](https://github.com/farcasterxyz/protocol/discussions/225) lands, which will allow a set of delegated wallets to take actions on behalf of a Farcaster account's custody wallet.
51-
</Info>
52-
</Tab>
5358
</Tabs>
5459

5560
## Deeplinks and SDK Actions
5661

57-
The official mini apps SDK offers a [set of actions](https://miniapps.farcaster.xyz/docs/specification#actions) (which MiniKit offers as well) so that users of your mini app can be led to do things back in clients like Coinbase Wallet (e.g. compose a cast, view a profile, etc).
62+
The official mini apps SDK offers a [set of actions](https://miniapps.farcaster.xyz/docs/specification#actions) (which MiniKit offers as well) so that users of your mini app can be led to do things back in clients like Base App (e.g. compose a cast, view a profile, etc).
5863

5964
<Warning>
6065
**Always use official SDK functions instead of Farcaster-specific deeplinks in your mini app.**
6166
</Warning>
6267

63-
While some developers have used Farcaster-specific deeplinks in the `openUrl` function as a workaround, this approach can create problems. Farcaster-specific deeplinks might not match Coinbase Wallet-specific deeplinks, **potentially leaving users dead-ended and unable to take further action in your mini app**.
64-
65-
Using the official SDK functions ensures your users have the best viewing experience possible across all supported clients, including Coinbase Wallet.
68+
While some developers have used Farcaster-specific deeplinks in the `openUrl` function as a workaround, this approach can create problems. Farcaster-specific deeplinks might not match Base App-specific deeplinks, **potentially leaving users dead-ended and unable to take further action in your mini app**.
6669

67-
<Info>
68-
Note: For developers who include a "Share" button in their miniapp, we recommend that you move over to the new `composeCast` function in the miniapps SDK instead of using a Farcaster-specific deeplink.
69-
</Info>
70+
Using the official SDK functions ensures your users have the best viewing experience possible across all supported clients, including Base App.
7071

7172
## Wallet Interactions
7273

73-
Wallet interactions are a core part of the miniapp experience. We want to ensure both that building wallet interactions on top of the Coinbase Wallet is smooth for developers and that users can choose/have funds sent to their Coinbase Wallet when interacting with mini apps.
74+
Wallet interactions are a core part of the miniapp experience. We want to ensure both that building wallet interactions on top of the Base App is smooth for developers and that users can choose/have funds sent to their Base App when interacting with mini apps.
7475

7576
As a mini app host, we expose an [EIP-1193 Ethereum Provider](https://eips.ethereum.org/EIPS/eip-1193) that can be accessed in two primary ways:
7677

@@ -83,19 +84,96 @@ If you run `npm create onchain --mini`, your mini app will have a "Connect Walle
8384
</Note>
8485
</Tab>
8586

86-
<Tab title="Frame SDK">
87-
By using either `sdk.wallet.getEthereumProvider()` from [@farcaster/frame-sdk](https://www.npmjs.com/package/@farcaster/frame-sdk) or by using [@farcaster/frame-wagmi-connector](https://www.npmjs.com/package/@farcaster/frame-wagmi-connector) with your Wagmi config
87+
<Tab title="Wagmi">
88+
[Wagmi](https://wagmi.sh) is a powerful JavaScript library for building Ethereum applications, and using it alongside any other onchain logic you have configured is very simple.
89+
It only takes the two steps below to auto-connect to the user's wallet with Wagmi:
90+
91+
1) Set up your WagmiProvider to use the Farcaster mini app connector
92+
```javascript
93+
import { createConfig, http, WagmiProvider } from "wagmi";
94+
import { base } from "wagmi/chains";
95+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
96+
import { farcasterFrame } from "@farcaster/frame-wagmi-connector";
97+
98+
export const config = createConfig({
99+
chains: [base],
100+
transports: {
101+
[base.id]: http()
102+
},
103+
connectors: [farcasterFrame()],
104+
});
105+
106+
const queryClient = new QueryClient();
107+
108+
export default function Provider({ children }: { children: React.ReactNode }) {
109+
return (
110+
<WagmiProvider config={config}>
111+
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
112+
</WagmiProvider>
113+
);
114+
}
115+
```
116+
117+
2) Listen for and use the auto-connected wallet session, if not connect the user
118+
119+
```javascript
120+
"use client";
121+
122+
import { useAccount, useConnect, useDisconnect } from "wagmi";
123+
import { config } from "~/components/providers/WagmiProvider";
124+
125+
export function WalletConnectMinimal() {
126+
const { address, isConnected } = useAccount();
127+
const { connect } = useConnect();
128+
const { disconnect } = useDisconnect();
129+
130+
return (
131+
<button onClick={() =>
132+
isConnected
133+
? disconnect()
134+
: connect({ connector: config.connectors[0] })}>
135+
{isConnected ? "Disconnect" : "Connect"}
136+
</button>
137+
);
138+
}
139+
```
140+
</Tab>
141+
142+
<Tab title="Browser Window">
143+
Because of the open standards this is built on top of, you can both listen for and connect to our injected wallet provider without installing any new package, directly from the browser window's DOM! There are two ways to do this that are both highlighted below:
144+
145+
Connect directly with `window.ethereum`
146+
```javascript
147+
// Check if provider exists
148+
if (window.ethereum) {
149+
// Use the provider directly
150+
const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
151+
const chainId = await window.ethereum.request({ method: 'eth_chainId' });
152+
}
153+
```
154+
155+
Use EIP-6963 discovery to listen for the provider's injection
156+
```javascript
157+
// Listen for provider announcements
158+
window.addEventListener('eip6963:announceProvider', (event) => {
159+
const provider = event.detail.provider;
160+
// Use the provider
161+
});
162+
163+
// Request providers
164+
window.dispatchEvent(new Event('eip6963:requestProvider'));
165+
```
88166
</Tab>
89167
</Tabs>
90168

91169
## Metadata
92170

93-
Farcaster has recently [extended the metadata spec for mini apps](https://github.com/farcasterxyz/miniapps/discussions/191), which allows developers to add screenshot links, categories, and more to their manifest (farcaster.json) file. Making use of these new metadata fields is highly recommended for increasing the chance that your mini app could be featured throughout Coinbase Wallet.
171+
Farcaster has recently [extended the metadata spec for mini apps](https://github.com/farcasterxyz/miniapps/discussions/191), which allows developers to add screenshot links, categories, and more to their manifest (farcaster.json) file. Making use of these new metadata fields is highly recommended for increasing the chance that your mini app could be featured throughout Base App.
94172

95173
Below is a table of the new metadata fields introduced, what they mean/could potentially be used for, and an example of what a manifest file could look like with these new fields (all taken from the [official spec](https://github.com/farcasterxyz/miniapps/discussions/191))
96174

97175
<Info>
98-
Note: Only ~30 of the hundreds of mini apps we've seen have set this data, we **highly recommend** that you set this metadata as it will give your mini app a better shot at being featured.
176+
Note: We **highly recommend** that you set this metadata as it will give your mini app a better shot at being featured throughout Base App.
99177
</Info>
100178

101179
<AccordionGroup>
@@ -165,7 +243,7 @@ Note: Only ~30 of the hundreds of mini apps we've seen have set this data, we **
165243
"tags": [
166244
"example",
167245
"mini app",
168-
"coinbase wallet"
246+
"Base App"
169247
],
170248
"heroImageUrl": "https://example.com/og.png",
171249
"tagline": "Example Mini App tagline",
@@ -178,7 +256,7 @@ Note: Only ~30 of the hundreds of mini apps we've seen have set this data, we **
178256

179257
## Notifications
180258

181-
You will soon be able to send notifications from your Mini App that will appear in Coinbase Wallet. These notifications help re-engage users when something important happens, like a new drop, an update, or a reminder to complete an action. There are two ways to integrate:
259+
You will soon be able to send notifications from your Mini App that will appear in Base App. These notifications help re-engage users when something important happens, like a new drop, an update, or a reminder to complete an action. There are two ways to integrate:
182260

183261
<Tabs>
184262
<Tab title="Use Neynar (Recommended)">
@@ -202,48 +280,54 @@ You can self-host your own backend as long as it follows the [Farcaster Mini App
202280
</Tab>
203281
</Tabs>
204282

205-
## Mini Apps Compatibility in Coinbase Wallet
283+
## Mini Apps Compatibility in Base App
206284

207-
Coinbase Wallet is working towards full compatibility with the Farcaster Mini App SDK. While we continue to enhance support during the beta phase, there are currently some features that are not yet supported.
285+
Base App is working towards full compatibility with the Farcaster Mini App SDK. While we continue to enhance support during the beta phase, there are currently some features that are not yet supported.
208286

209287
### AI-Powered Compatibility Checking
210-
We provide a [validate.txt](https://raw.githubusercontent.com/base/demos/refs/heads/master/minikit/mini-app-help/validate.txt) file that can be used with AI tools to automatically check your codebase for Coinbase Wallet compatibility issues. Similar to llms.txt files, you can provide this validation file to language models to scan your Mini App code and receive a detailed compatibility report highlighting any unsupported features or patterns.
288+
We provide a [validate.txt](https://raw.githubusercontent.com/base/demos/refs/heads/master/minikit/mini-app-help/validate.txt) file that can be used with AI tools to automatically check your codebase for Base App compatibility issues. Similar to llms.txt files, you can provide this validation file to language models to scan your Mini App code and receive a detailed compatibility report highlighting any unsupported features or patterns.
211289

212290
<Warning>
213291
This AI validation is experimental and should only be used in a read-only capacity for analysis and reporting purposes.
214292
</Warning>
215293

216294
### Currently Unsupported Features
217295

218-
The following Mini App SDK features are **not currently supported** in Coinbase Wallet:
296+
The following Mini App SDK features are **not currently supported** in Base App:
219297

220298
#### Environment Detection
221-
222299
* `sdk.isInMiniApp()`
223300

224301
#### Haptic Feedback
225-
226-
* All haptic-related SDK methods
302+
* All haptic related SDK methods
303+
* `sdk.haptics.impactOccurred()`
304+
* `sdk.haptics.notificationOccurred()`
305+
* `sdk.haptics.selectionChanged()`
227306

228307
#### Token Actions
308+
* `sdk.actions.swapToken()`
309+
* `sdk.actions.sendToken()`
229310

230-
* `sdk.actions.swapToken` \- Token swapping functionality
231-
* `sdk.actions.sendToken` \- Token sending functionality
232-
* `sdk.actions.viewToken` \- Token viewing functionality
311+
### Wallet Interactions
312+
* `sdk.actions.getEthereumProvider()`
313+
* Note: We still expose an [EIP-1193 Ethereum Provider](https://eips.ethereum.org/EIPS/eip-1193) that you can auto-detect or use in a package such as MiniKit/Wagmi
233314

234315
#### Navigation & Links
235316

236-
* Direct HTML links (`<a href=`, `<Link href=`)
237-
* Warpcast composer URLs (`warpcast.com/~/compose`, `farcaster.com/~/compose`)
317+
* Direct HTML links to third-party websites (`<a href=`, `<Link href=`)
318+
* Note: You can instead use `sdk.actions.openUrl()` to safely open a third-party website in our in-app browser
319+
* Warpcast/Farcaster composer intent URLs (`warpcast.com/~/compose`, `farcaster.com/~/compose`)
320+
* Note: You can instead use `sdk.actions.composeCast()` to compose a cast directly in Base App
238321

239322
#### Context Features
240323

241-
* `Share extensions` \- Because share extensions heavily rely on context this will not work in CBW.
242-
* `sdk.context.location` \- Share link detection and embed context
324+
* Share extensions
325+
* `sdk.context.location`
243326

244327
#### Supported Chains
245328

246329
* Base
330+
* Mainnet
247331
* Optimism
248332
* Arbitrum
249333
* Polygon
@@ -258,7 +342,7 @@ The following Mini App SDK features are **not currently supported** in Coinbase
258342
* Use `sdk.actions.composeCast()` instead of Warpcast composer URLs
259343
* Implement visual feedback alternatives for haptic feedback
260344
* Avoid relying on location context for core functionality
261-
* To conditionally render functionality based on the user's client, check context.client.clientFid (Coinbase Wallet returns 309857)
345+
* To conditionally render functionality based on the user's client, check `context.client.clientFid` (Base App returns `309857`)
262346

263347
We are actively working to expand compatibility and expect to support additional features in future releases.
264348

0 commit comments

Comments
 (0)