Skip to content

Commit

Permalink
Update MetaMask connector doc (#4425)
Browse files Browse the repository at this point in the history
* Update MetaMask connector doc

Update docs page for the MetaMask SDK connector. This includes removing several options that we don't recommend configuring.

* Address reviewer comments

* update link

* fix dappMetadata description
  • Loading branch information
alexandratran authored Nov 27, 2024
1 parent e563ef6 commit 9eb222c
Showing 1 changed file with 28 additions and 108 deletions.
136 changes: 28 additions & 108 deletions site/shared/connectors/metaMask.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const connectorsPackageName = 'wagmi/connectors'

# metaMask

Connector for the [MetaMask SDK](https://github.com/MetaMask/metamask-sdk).
Connector for [MetaMask SDK](https://github.com/MetaMask/metamask-sdk).

## Import

Expand Down Expand Up @@ -36,133 +36,53 @@ export const config = createConfig({
```ts-vue
import { type MetaMaskParameters } from '{{connectorsPackageName}}'
```
Check out the [MetaMask SDK docs](https://github.com/MetaMask/metamask-sdk?tab=readme-ov-file#sdk-options) for more info. A few options are omitted that Wagmi manages internally.

### communicationLayerPreference

`CommunicationLayerPreference | undefined`

The preferred communication layer to use for the SDK.

### communicationServerUrl

`string | undefined`

The URL of the communication server to use for the SDK.
Check out the [MetaMask SDK docs](https://docs.metamask.io/wallet/connect/3rd-party-libraries/wagmi/) for more info. A few options are omitted that Wagmi manages internally.

### dappMetadata

`DappMetadata | undefined`

- Metadata about the dapp using the SDK.
- Defaults to `{ name: 'wagmi' }`.

### enableAnalytics

`boolean | undefined`

- Send anonymous analytics to MetaMask to help us improve the SDK.
- Defaults to `false`.

### extensionOnly

`boolean | undefined`

- If MetaMask browser extension is detected, directly use it.
- Defaults to `true`.

### forceDeleteProvider <Badge type="warning">deprecated</Badge>

`boolean | undefined`

If true, the SDK will force delete the provider from the global `window` object.


### forceInjectProvider <Badge type="warning">deprecated</Badge>

`boolean | undefined`

If true, the SDK will force inject the provider into the global `window` object.

### infuraAPIKey
Metadata about the dapp using the SDK, including, `name`, `url`, and `iconUrl`.
By default, `url` gets its value from `window.location.origin`.

`string | undefined`

The Infura API key to use for RPC requests.

### injectProvider <Badge type="warning">deprecated</Badge>

`boolean | undefined`
```ts-vue
import { metaMask } from '{{connectorsPackageName}}'
If true, the SDK will inject the provider into the global `window` object.
const connector = metaMask({
dappMetadata: { // [!code focus]
name: 'My Wagmi App', // [!code focus]
url: 'https://example.com', // [!code focus]
iconUrl: 'https://example.com/favicon.ico', // [!code focus]
}
})
```

### logging

`SDKLoggingOptions | undefined`

Options for customizing the logging behavior of the SDK.

### modals

`RemoteConnectionProps['modals'] | undefined`

An object that allows you to customize or translate each of the displayed modals. See the nodejs example for more information.

### openDeeplink

`((arg: string) => void) | undefined`

A function that will be called to open a deeplink to the MetaMask Mobile app.

### preferDesktop
### headless

`boolean | undefined`

If true, the SDK will prefer the desktop version of MetaMask over the mobile version.

### shouldShimWeb3

`boolean | undefined`

If true, the SDK will shim the window.web3 object with the provider returned by the SDK (useful for compatibility with older browser).

### storage

`StorageManagerProps | undefined`

Options for customizing the storage manager used by the SDK.

### timer
Enables or disables headless mode.
Setting this to `true` disables the MetaMask modal, allowing you to create your own UI.
To get the deeplink to display in the QR code, listen to the `display_uri` event.

`any | undefined`
The default is `false`.

A timer object to use for scheduling tasks.

### transports

`string[] | undefined`

An array of transport protocols to use for communication with the MetaMask wallet.

### ui

`SDKUIOptions | undefined`

Options for customizing the SDK UI.

### useDeeplink <Badge type="warning">deprecated</Badge>

`boolean | undefined`

- If `true`, the SDK will use deeplinks to connect with MetaMask Mobile. If `false`, the SDK will use universal links to connect with MetaMask Mobile.
- Defaults to `true`.

::: warning
Setting `useDeeplink` to `false` can negatively impact performance on iOS Safari as Universal Link connections are canceled if they do not occur within ~500ms of an interaction (e.g. button press).
:::
```ts-vue
import { metaMask } from '{{connectorsPackageName}}'
### wakeLockType
const connector = metaMask({
headless: true // [!code focus]
})
```

`WakeLockStatus | undefined`
## Advanced

The type of wake lock to use when the SDK is running in the background.
By default, if the EIP-6963 MetaMask injected provider is detected, this connector will replace it.
See the [`rdns` property](https://wagmi.sh/dev/creating-connectors#properties) for more information.

0 comments on commit 9eb222c

Please sign in to comment.