Getting Started
You can get started by creating a new project or adding thirdweb to an existing project.
New Projects
You can quickly create a new project with the thirdweb CLI
or clone the the Next.js or Vite starter repo:
Existing Projects
Install the thirdweb packages in your project
Build your app
Setup the ThirdwebProvider
At the root of your application, wrap your app with a
ThirdwebProvider
component. This keeps state around like the active wallet and chain.Create the thirdweb client
Head to the thirdweb dashboard, create your account (or sign in), and click Settings to reach the api keys page.
Create an API key with
localhost
included in the allowed domains. Securely store your secret key and copy your client id for use in the next step.Create a
.env
file and add your client ID there. Then create aclient.ts
file with the following content:You only need to define the client once. Exporting the client vartiable will allow you to use anywhere in your app.
Connect a wallet
There are two ways to connect users to your app:
- The prebuilt
ConnectButton
orConnectEmbed
components. - Your own custom button.
In this guide, we'll use the prebuilt
ConnectButton
component.The
ConnectButton
andConnectEmbed
components come with built-in support for 350+ of wallets, 2000+ chains, fiat on-ramping, crypto swapping, transaction tracking, and more.You can also build your own custom button using the
useConnect
hook.- The prebuilt
Get the connected wallet information
Once the user has connected their wallet, you can get the wallet address, balance, and other details.
Read blockchain data
You can read contract state with the
useReadContract
hook. This works with any contract call. Simply specify the solidity function signature to get a type safe API for your contract.Using Extensions you can do powerful queries like getting all the owned NFTs of a specific address, and generate performant typesafe functions for your contract.
Execute transactions
You can execute transactions with the
useSendTransaction
hook. Prepare a transaction with theprepareContractCall
function and pass it to thesendTransaction
function.Using Extensions you can do more complex transactions like a claim, batch mint, and more. These will handle all the preprocessing needed before calling the contract.
Learn more
You know have all the basics to build your own app with thirdweb. You can also check out the thirdweb SDK reference to learn more about the different hooks and functions available.