Clerk logo

Clerk Docs

Ctrl + K
Go to clerkstage.dev
Check out a preview of our new docs.

<SignInWithMetamaskButton/>

Sign in with Metamask Web3 wallet in the browser

Overview

The <SignInWithMetamaskButton/> component is used to complete a one-click, cryptographically-secure login flow using MetaMask, with all data stored on the Clerk user.

Internally, it calls the Clerk.authenticateWithMetamask() method.

Usage

Make sure you've followed the installation guide for Clerk React before running the snippets below.

The most common scenario for using the <SignInWithMetamaskButton/> component is to execute a Metamask sign in or sign up flow in React and NextJS apps.

1
import React from 'react';
2
import { render } from 'react-dom';
3
import {
4
ClerkProvider,
5
SignedIn,
6
SignedOut,
7
UserButton,
8
SignInWithMetamaskButton,
9
} from '@clerk/clerk-react';
10
11
function App() {
12
return (
13
<ClerkProvider publishableKey="clerk-pub-key">
14
<SignedIn>
15
<UserButton />
16
</SignedIn>
17
<SignedOut>
18
<SignInWithMetamaskButton />
19
</SignedOut>
20
</ClerkProvider>
21
);
22
}
23
24
render(<App />, document.getElementById('root'));

Props

NameTypeDescription
redirectUrl?string

Full URL or path to navigate after successful sign in or sign up.

Simple button

1
<SignInWithMetamaskButton />

Custom button

1
<SignInWithMetamaskButton>
2
<button className="btn">
3
Web3 authentication rocks!
4
</button>
5
</SignInWithMetamaskButton>

Was this helpful?

Clerk © 2023