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

# Thirdweb

> Configure Thirdweb with Base Account for your React application

export const GithubRepoCard = ({title, githubUrl}) => {
  return <a href={githubUrl} target="_blank" rel="noopener noreferrer" className="mb-4 flex items-center rounded-lg bg-zinc-900 p-4 text-white transition-all hover:bg-zinc-800">
      <div className="flex w-full items-center gap-3">
        <svg height="24" width="24" className="flex-shrink-0 dark:fill-white" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
          <path fill="currentColor" fillRule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" />
        </svg>

        <div className="flex min-w-0 flex-grow flex-col">
          <span className="truncate text-base font-medium">{title}</span>
          <span className="truncate text-xs text-zinc-400">{githubUrl}</span>
        </div>

        <svg className="h-5 w-5 flex-shrink-0 text-zinc-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
          <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
        </svg>
      </div>
    </a>;
};

Learn how to set up Thirdweb with Base Account 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 Base Account,
you can leverage Thirdweb's `ConnectButton` component
while providing users with native Base Account wallet support.

### What you'll achieve

By the end of this guide, you will:

* Set up Thirdweb with Base Account support
* Have Base Account 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 [Base Account Thirdweb Template](https://github.com/base/demos/tree/main/base-account/base-account-thirdweb-template) to get started.

<GithubRepoCard title="Base Account Thirdweb Template" githubUrl="https://github.com/base/demos/tree/main/base-account/base-account-thirdweb-template" />

## Installation

### 1. Create a new Next.js project

<CodeGroup>
  ```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
  ```
</CodeGroup>

### 2. Install the dependencies

Install the Thirdweb SDK (version 5.118.0 or higher is required for Base Account support):

<CodeGroup>
  ```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
  ```
</CodeGroup>

## Configuration

### 1. Set up Environment Variables

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

```bash 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:

<CodeGroup>
  ```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) expandable theme={null}
  import type { Metadata } from "next";
  import "./globals.css";
  import Providers from "@/providers/providers";

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

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

## Usage

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

```tsx src/app/page.tsx 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:

<CodeGroup>
  ```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
  ```
</CodeGroup>

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

<div style={{ display: 'flex', justifyContent: 'center'}}>
  <img src="https://mintcdn.com/base-a060aa97/DP4VZr8ZrLssMEMp/images/base-account/Thirdweb-Base-Account.png?fit=max&auto=format&n=DP4VZr8ZrLssMEMp&q=85&s=7bb1840eb6049860b44e2acac9d4ef1c" alt="Base × Thirdweb Demo" style={{ width: '600px', height: 'auto' }} width="1266" height="643" data-path="images/base-account/Thirdweb-Base-Account.png" />
</div>

## Customization

### Wallet Options

You can customize which wallets appear in the connect modal:

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

// Base Account 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={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 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)
