Getting Started
You can get started by creating a new project or adding thirdweb to an existing project.
You can quickly create a new project with the thirdweb CLI
or clone the the Next.js or Vite starter repo:
Install the thirdweb packages in your project
At the root of your application, wrap your app with a
ThirdwebProvider
component. This keeps state around like the active wallet and chain.Head to the thirdweb dashboard, create your account (or sign in), and click Projects to see all your projects.
Create a Project 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.
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
Once the user has connected their wallet, you can get the wallet address, balance, and other details.
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.
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.
You know have all the basics to build your own app with thirdweb. You can also check out the full thirdweb SDK reference to learn more about the different hooks and functions available.