> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cdp.coinbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# thirdweb

> Configure Thirdweb with Coinbase Wallet for your React application

Learn how to set up Thirdweb with Coinbase Wallet to enable seamless user authentication and wallet management.

## Overview

[Thirdweb](https://thirdweb.com/) provides a complete onchain application development framework with wallet connection, authentication, and smart contract interactions.
By integrating Thirdweb with Coinbase Wallet,
you can leverage Thirdweb's `ConnectButton` component
while providing users with native Coinbase Wallet support.

### What You'll Achieve

By the end of this guide, you will:

* Set up Thirdweb with Coinbase Wallet support
* Have Coinbase Wallet available as a wallet option alongside email authentication
* Use Thirdweb's `ConnectButton` for a polished wallet connection experience

You can jump ahead and use the [Coinbase Wallet Thirdweb Template](https://github.com/base/demos/tree/main/base-account/base-account-thirdweb-template) to get started.

[Coinbase Wallet thirdweb Template
https://github.com/base/demos/tree/main/base-account/base-account-thirdweb-template](https://github.com/base/demos/tree/main/base-account/base-account-thirdweb-template)

## Installation

### 1. Create a New Next.js Project

```bash npm theme={null}
npx create-next-app@latest base-account-thirdweb
cd base-account-thirdweb
```

```bash yarn theme={null}
yarn create next-app base-account-thirdweb
cd base-account-thirdweb
```

```bash pnpm theme={null}
pnpm create next-app base-account-thirdweb
cd base-account-thirdweb
```

```bash bun theme={null}
bun create next-app base-account-thirdweb
cd base-account-thirdweb
```

### 2. Install the Dependencies

Install the Thirdweb SDK (version 5.118.0 or higher is required for Coinbase Wallet support):

```bash npm theme={null}
npm install thirdweb@^5.118.0
```

```bash yarn theme={null}
yarn add thirdweb@^5.118.0
```

```bash pnpm theme={null}
pnpm add thirdweb@^5.118.0
```

```bash bun theme={null}
bun add thirdweb@^5.118.0
```

## Configuration

### 1. Set Up Environment Variables

Create a `.env.local` file in your project root:

```bash .env.local theme={null}
NEXT_PUBLIC_THIRDWEB_CLIENT_ID=your-client-id
```

Get your Client ID from the [Thirdweb Dashboard](https://thirdweb.com/dashboard).

### 2. Create the thirdweb Client

Create a client configuration file:

```ts src/lib/client.ts theme={null}
import { createThirdwebClient } from "thirdweb";

export const client = createThirdwebClient({
  clientId: process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID!,
});
```

### 3. Configure ThirdwebProvider

Create a providers wrapper component and update your layout:

```tsx Create Provider (src/providers/providers.tsx) expandable theme={null}
"use client";

import { ThirdwebProvider } from "thirdweb/react";

export default function Providers({ children }: { children: React.ReactNode }) {
  return <ThirdwebProvider>{children}</ThirdwebProvider>;
}
```

```tsx Add to Layout (src/app/layout.tsx) lines wrap expandable theme={null}
import type { Metadata } from "next";
import "./globals.css";
import Providers from "@/providers/providers";

export const metadata: Metadata = {
  title: "Coinbase Wallet Thirdweb Template",
  description: "Build on Base with Thirdweb's authentication and Coinbase Wallet support",
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <body className="antialiased">
        <Providers>{children}</Providers>
      </body>
    </html>
  );
}
```

## Usage

Use Thirdweb's `ConnectButton` with your wallet configuration:

```tsx src/app/page.tsx lines wrap expandable theme={null}
"use client";

import dynamic from "next/dynamic";
import { lightTheme } from "thirdweb/react";
import { inAppWallet, createWallet } from "thirdweb/wallets";
import { base } from "thirdweb/chains";
import { client } from "@/lib/client";

// Dynamic import to avoid SSR hydration issues
const ConnectButton = dynamic(
  () => import("thirdweb/react").then((mod) => mod.ConnectButton),
  { ssr: false }
);

// Configure wallets
const emailWallet = inAppWallet({
  auth: {
    options: ["email"],
  },
});

const baseAccountWallet = createWallet("org.base.account");
const wallets = [emailWallet, baseAccountWallet];
const recommendedWallets = [baseAccountWallet];

// Custom theme (optional)
const customTheme = lightTheme({
  colors: {
    primaryButtonBg: "#0052FF",
    primaryButtonText: "#FFFFFF",
    accentText: "#0052FF",
  },
});

export default function Home() {
  return (
    <main className="min-h-screen flex items-center justify-center">
      <ConnectButton
        client={client}
        wallets={wallets}
        recommendedWallets={recommendedWallets}
        chain={base}
        showAllWallets={false}
        theme={customTheme}
        connectButton={{
          label: "Sign In",
        }}
        connectModal={{
          title: "Sign In",
          size: "compact",
        }}
      />
    </main>
  );
}
```

### 3. Run the Project Locally

You're done! Run the project locally:

```bash npm theme={null}
npm run dev
```

```bash yarn theme={null}
yarn dev
```

```bash pnpm theme={null}
pnpm dev
```

```bash bun theme={null}
bun dev
```

You should see a page with a "Sign In" button. Clicking it will open the Thirdweb connect modal with Coinbase Wallet and email authentication options.

![Base × Thirdweb Demo](https://mintcdn.com/coinbase-prod/3bNJxHqx_waLDC5R/images/base-account/Thirdweb-Base-Account.png?fit=max\&auto=format\&n=3bNJxHqx_waLDC5R\&q=85\&s=1d5dfafd03f5050c6ba0d242dbdff2c0)

## Customization

### Wallet Options

You can customize which wallets appear in the connect modal:

```tsx Wallet Options lines wrap expandable theme={null}
// Email only
const wallets = [inAppWallet({ auth: { options: ["email"] } })];

// Coinbase Wallet only
const wallets = [createWallet("org.base.account")];

// Multiple options including social logins
const wallets = [
  inAppWallet({
    auth: {
      options: ["email", "google", "apple", "discord"],
    },
  }),
  createWallet("org.base.account"),
];
```

### Theme

Customize the appearance using `lightTheme` or `darkTheme`:

```tsx Theme Options lines wrap expandable theme={null}
import { lightTheme, darkTheme } from "thirdweb/react";

// Light theme with custom colors
const theme = lightTheme({
  colors: {
    primaryButtonBg: "#0052FF",
    accentText: "#0052FF",
    modalBg: "#FFFFFF",
  },
});

// Or use dark theme
const theme = darkTheme();
```

### Chain

Change the default chain by importing from `thirdweb/chains`:

```tsx Chain Configuration theme={null}
import { base, baseSepolia, mainnet } from "thirdweb/chains";

<ConnectButton
  client={client}
  chain={baseSepolia} // Use Base Sepolia testnet
  // ...
/>
```

## Resources

* [Thirdweb Documentation](https://portal.thirdweb.com)
* [Thirdweb ConnectButton Reference](https://portal.thirdweb.com/references/typescript/v5/ConnectButton)
* [Next.js Documentation](https://nextjs.org/docs)
* [Base Support](https://discord.com/invite/buildonbase)
