Base Blockchain  

Onboard Any User onto Base Blockchain Using OnchainKit

Introduction

This article shows how to help anyone start using the Base blockchain, even if they don’t know much about crypto. Using a tool called OnchainKit, we can let users sign in with just their email, create a wallet for them, and connect them to Base without needing extra apps like MetaMask. They can then do things like mint NFTs or send tokens easily. It’s simple, fast, and great for beginners who want to try blockchain without any confusion.

Onboarding Users to Base with OnchainKit

Step 1. Create a project

In this step, we are installing an Onchain toolkit, which is used to create a new Onchain application using npm (Node Package Manager).

npm create onchain@latest

Onchain

In the above screenshot, you can see that after running the npm create onchain@latest command, I have to enter the Project Name, CDP(Coinbase Developer Platform) Client API Key , after entering that , the new Onchainkit Project is created .

Step 2. Navigate to the Project

cd onchainkit-base-app

Navigate the project

Step 3. Install Dependencies

npm install

Install npm

After installing dependencies, you will automatically get the directory structure like this:

Directory structure

Step 4. Run the Development Server

npm run dev

The npm run dev command is used to start your application in development mode. When you run this command in a project like your onchainkit-base-app (built with Next.js), it launches a local development server that enables you to:

  • Preview your app locally at http://localhost:3000
  • See real-time updates as you edit files
  • Automatically reload the page on code changes 
  • Get developer-friendly error messages and debugging info

Run

Visit http://localhost:3000 in your browser to see your app running.

OnchainKit

Step 5. Add API Key to .env.local

NEXT_PUBLIC_ONCHAINKIT_API_KEY=your-api-key-here

Note.  In this, you have to add your API key and Project Name inside your .env file.

Explorer

Step 6. Customize src/providers.tsx

Ensure this file sets up the OnchainKitProvider with your API key and modal settings.

import { OnchainKitProvider } from "@onchainkit/react";
import { base } from "viem/chains";

export const Providers = ({ children }) => (
  <OnchainKitProvider
    apiKey={process.env.NEXT_PUBLIC_ONCHAINKIT_API_KEY}
    chain={base}
    config={{
      appearance: {
        name: "My Base App",
        logo: "https://your-logo-url.com/logo.png",
        mode: "auto",
        theme: "default",
      },
      wallet: {
        display: "modal",
        termsUrl: "https://your-app.com/terms",
        privacyUrl: "https://your-app.com/privacy",
      },
    }}
  >
    {children}
  </OnchainKitProvider>
);

This file is a core setup file that configures and wraps your entire React application with Web3 context providers. The provider.tsx file typically:

  • Sets up Wagmi, a React hooks library for Ethereum.
  • Defines blockchain networks (like Base, Ethereum, etc.)
  • Adds wallet connectors (e.g., Injected, Coinbase Wallet)
  • Wraps your app in <WagmiConfig> – so that all components can use Web3 features like connecting a wallet or reading blockchain data.
    Localhost

Step 7. Update Your src/pages/App.tsx

Use the Wallet component to allow users to connect wallets.

import {
  Wallet,
  ConnectWallet,
  WalletDropdown,
  WalletDropdownDisconnect,
  Identity,
  Avatar,
  Name,
  Address,
  EthBalance,
} from "@onchainkit/react";

export default function Home() {
  return (
    <div className="my-10 flex justify-center">
      <Wallet>
        <ConnectWallet>
          <Avatar className="h-6 w-6" />
          <Name />
        </ConnectWallet>
        <WalletDropdown>
          <Identity className="px-4 pt-3 pb-2" hasCopyAddressOnClick>
            <Avatar />
            <Name />
            <Address />
            <EthBalance />
          </Identity>
          <WalletDropdownDisconnect />
        </WalletDropdown>
      </Wallet>
    </div>
  );
}

The app.tsx file is the main landing page or home component of your dApp. It's the central UI file that users see first when they open your app. This file brings together the design and logic for:

  • The Wallet Connect button
  • User Identity (avatar, address, balance)
  • A logo/image
  • Navigation links to other OnchainKit components and templates

In this, you can see that I linked my Coinbase wallet.

Linked Coinbase wallet

 You can copy your wallet address by clicking on this.

Wallet address 

When you click on the wallet button, you will be redirected to https://wallet.coinbase.com/smart-wallet.

Wallet

Here you can create your smart wallet.

Home

You also have an option to disconnect your wallet.

Disconnect

Conclusion

By using OnchainKit with the WalletModal component, you can easily let anyone join your app on the Base blockchain, whether they already have a wallet or need to create a new one. The setup is quick, the interface looks great on all devices, and it works smoothly for both beginners and experienced users. With features like Smart Wallets, passkey login, and easy wallet management, your app becomes more user-friendly and ready for real-world blockchain use.