### Run Development Server using Package Managers Source: https://github.com/coinbase/onchainkit/blob/main/templates/onchainkit-nextjs/README.md Starts the Next.js development server, allowing you to see live updates as you code. This command can be executed with npm, yarn, pnpm, or bun. ```bash npm run dev ``` ```bash yarn dev ``` ```bash pnpm dev ``` ```bash bun dev ``` -------------------------------- ### Complete Migration Steps Source: https://github.com/coinbase/onchainkit/blob/main/alpha-upgrade-guide.md Consolidated migration steps for upgrading to OnchainKit v1.0.0, including updating dependencies, adjusting the provider setup, and changing package references. ```bash Step 1: Update Dependencies npm install @coinbase/onchainkit@1.0.0 react@19 react-dom@19 viem@^2.27 wagmi@^2.16 Step 2: Update Provider Replace MiniKitProvider with OnchainKitProvider and add MiniKit configuration. Step 3: Update Package References Change @farcaster/frame-sdk to @farcaster/miniapp-sdk in your package.json. ``` -------------------------------- ### Update Provider Setup (React) Source: https://github.com/coinbase/onchainkit/blob/main/alpha-upgrade-guide.md Compares the 'Before' (v0.x using MiniKitProvider) and 'After' (v1.0 using OnchainKitProvider) configurations for setting up the OnchainKit provider in a React application. Highlights the consolidation of MiniKitProvider into OnchainKitProvider and new configuration options. ```tsx // Before (v0.x): import { MiniKitProvider } from "@coinbase/onchainkit/minikit"; export function Providers({ children }) { return ( {children} ); } // After (v1.0): import { OnchainKitProvider } from "@coinbase/onchainkit"; import "@coinbase/onchainkit/styles.css"; export function RootProvider({ children }) { return ( {children} ); } ``` -------------------------------- ### Install Required Peer Dependencies (npm) Source: https://github.com/coinbase/onchainkit/blob/main/alpha-upgrade-guide.md This command installs the necessary peer dependencies, `viem` and `wagmi`, for OnchainKit v1.0.0. Ensure these versions are installed to avoid build failures and peer dependency warnings. These libraries are crucial for blockchain interaction within the OnchainKit framework. ```bash npm install viem@^2.27 wagmi@^2.16 ``` -------------------------------- ### Bootstrap New OnchainKit Project Source: https://github.com/coinbase/onchainkit/blob/main/alpha-upgrade-guide.md Command to initialize a new project with OnchainKit v1.0.0@alpha. Supports both traditional and mini web applications. ```bash npx create-onchain@alpha // Traditional web app npx create-onchain@alpha --mini // Mini app ``` -------------------------------- ### Start Development Server with pnpm Source: https://github.com/coinbase/onchainkit/blob/main/packages/create-onchain/README.md Start the development server for the project using pnpm. This command typically builds the project and launches a local server for development and testing purposes. ```bash pnpm dev ``` -------------------------------- ### Install Dependencies for OnchainKit Source: https://github.com/coinbase/onchainkit/blob/main/examples/minikit-example/README.md Installs project dependencies using various package managers like npm, yarn, pnpm, and bun. Ensure you have the chosen package manager installed. ```bash npm install # or yarn install # or pnpm install # or bun install ``` -------------------------------- ### Run OnchainKit Development Server Source: https://github.com/coinbase/onchainkit/blob/main/examples/minikit-example/README.md Starts the development server for the OnchainKit project, allowing for hot-reloading and immediate feedback during development. This command is compatible with npm, yarn, pnpm, and bun. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Clone OnchainKit Repository Source: https://github.com/coinbase/onchainkit/blob/main/README.md This command clones the OnchainKit repository from GitHub, allowing you to access the project files and begin the setup process. ```bash git clone https://github.com/coinbase/onchainkit.git ``` -------------------------------- ### Install Dependencies with pnpm Source: https://github.com/coinbase/onchainkit/blob/main/README.md Installs all project dependencies using pnpm, which is required for managing the monorepo structure and its packages. Ensure you have pnpm v10 installed. ```bash pnpm install ``` -------------------------------- ### Develop and Watch Playground Source: https://github.com/coinbase/onchainkit/blob/main/README.md Builds OnchainKit in watch mode and starts the playground for live component viewing. This command is essential for iterative development of UI components and utilities. ```bash pnpm f:play dev:watch ``` -------------------------------- ### Create Onchain CLI Help and Version Commands Source: https://github.com/coinbase/onchainkit/blob/main/packages/create-onchain/README.md Display help information and the current version of the Create Onchain CLI tool. The --help flag shows all available commands and options, while the --version flag displays the installed version number. ```bash npx create-onchain --help npx create-onchain --version ``` -------------------------------- ### Apply Scoped Styling Source: https://github.com/coinbase/onchainkit/blob/main/alpha-upgrade-guide.md Example of applying OnchainKit's scoped styling system by setting a data attribute on the HTML element. This ensures styles are isolated and prevents conflicts with consumer app theming. ```tsx // Themes are applied via data attribute to prevent conflicts {/* Your app content */} ``` -------------------------------- ### ConnectWallet Component with Render Props Source: https://github.com/coinbase/onchainkit/blob/main/alpha-upgrade-guide.md Demonstrates how to use the render prop pattern with the ConnectWallet component in OnchainKit v1.0.0 for complete customization of the button's appearance and behavior. ```tsx // ConnectWallet with render prop ( )} /> ``` -------------------------------- ### Update Project Dependencies Source: https://github.com/coinbase/onchainkit/blob/main/alpha-upgrade-guide.md Commands to update project dependencies to OnchainKit v1.0.0 and required peer dependencies like viem and wagmi. Supports both npm and pnpm package managers. ```bash npm install @coinbase/onchainkit@1.0.0 viem@^2.27 wagmi@^2.16 pnpm add @coinbase/onchainkit@1.0.0 viem@^2.27 wagmi@^2.16 ``` -------------------------------- ### Upgrade React for Compatibility (npm) Source: https://github.com/coinbase/onchainkit/blob/main/alpha-upgrade-guide.md This command upgrades your project to React 19 and ReactDOM 19. This is a requirement for OnchainKit v1.0.0 to ensure compatibility and avoid potential errors. Ensure your project is set up to use the latest React versions. ```bash npm install react@19 react-dom@19 ``` -------------------------------- ### SignatureButton Component with Render Props Source: https://github.com/coinbase/onchainkit/blob/main/alpha-upgrade-guide.md Illustrates the usage of render props with the SignatureButton component in OnchainKit v1.0.0, allowing for custom rendering and control over the button's presentation. ```tsx // SignatureButton with render prop ( )} /> ``` -------------------------------- ### Update Farcaster SDK Dependency Source: https://github.com/coinbase/onchainkit/blob/main/alpha-upgrade-guide.md Shows the change in the Farcaster SDK dependency in package.json from '@farcaster/frame-sdk' in v0.x to '@farcaster/miniapp-sdk' in v1.0. ```json // Before (v0.x): { "dependencies": { "@farcaster/frame-sdk": "^0.1.8" } } // After (v1.0): { "dependencies": { "@farcaster/miniapp-sdk": "^0.1.8" } } ``` -------------------------------- ### Execute Transactions with Raw Calls Source: https://context7.com/coinbase/onchainkit/llms.txt This example demonstrates executing blockchain transactions using raw call data, bypassing the need for contract ABIs. The `Transaction` component is used with a chain ID and a list of `Call` objects, where each `Call` specifies the recipient address (`to`), optional data (`data`), and optional value (`value`). This approach is useful for interacting with contracts where ABIs are not readily available or for simpler, direct contract interactions. UI components like `TransactionButton` and `TransactionStatus` are included for user interaction. ```tsx import { Transaction, TransactionButton, TransactionStatus, TransactionStatusLabel, } from '@coinbase/onchainkit/transaction'; import type { Hex } from 'viem'; type Call = { to: Hex; data?: Hex; value?: bigint }; function RawTransactionComponent() { const calls: Call[] = [ { to: '0x1234567890123456789012345678901234567890', data: '0x01ffc9a7', value: BigInt(0), }, ]; return ( ); } ``` -------------------------------- ### Update Custom Theming CSS Variables to --ock- Prefix Source: https://github.com/coinbase/onchainkit/blob/main/alpha-upgrade-guide.md This snippet demonstrates how to update custom CSS variables for OnchainKit theming. It shows the transition from v0.x to v1.0.0, where a new prefix `--ock-` is required for custom theme variables. Ensure your custom styles adhere to this new naming convention. ```css /* Before (v0.x) */ :root { --text-primary: #000000; --bg-primary: #ffffff; } /* After (v1.0) */ [data-ock-theme='custom'] { --ock-text-foreground: #000000; --ock-background: #ffffff; } ``` -------------------------------- ### Wallet Connection and Management with OnchainKit Source: https://context7.com/coinbase/onchainkit/llms.txt Implements wallet connection and account management using OnchainKit's Wallet components. It utilizes Wagmi's `useAccount` hook to get the user's address and displays wallet information within a dropdown menu. Components like `ConnectWallet`, `WalletDropdown`, `Identity`, `Name`, `Address`, `EthBalance`, and `Socials` are used. ```tsx import { ConnectWallet, Wallet, WalletDropdown, WalletDropdownBasename, WalletDropdownDisconnect, WalletDropdownFundLink, WalletDropdownLink, } from '@coinbase/onchainkit/wallet'; import { Address, Avatar, EthBalance, Identity, Name, Socials, } from '@coinbase/onchainkit/identity'; import { useAccount } from 'wagmi'; function WalletComponent() { const { address } = useAccount(); return (
Wallet ); } ``` -------------------------------- ### Create New Project with Create Onchain CLI Source: https://github.com/coinbase/onchainkit/blob/main/packages/create-onchain/README.md Bootstrap a new project using the Create Onchain CLI. This command initializes a project with predefined templates and configurations. It supports creating a default OnchainKit template, a MiniKit template for Farcaster Mini-Apps, or specific templates using the --template flag. ```bash npx create-onchain npx create-onchain --mini npx create-onchain --template-