Getting Started
To get started, install the required dependencies into your React project.
- Existing Projects
- New Projects
npm install @thirdweb-dev/react @thirdweb-dev/sdk "ethers@^5"
Required Configuration
Create React App
Vite
Next.js
npx thirdweb create app
API Key
You will require an API key to use thirdweb's infrastructure services with the SDK. If you haven't created a key yet you can do so for free from the thirdweb dashboard.
Wrap your application in ThirdwebProvider
Wrap your application in the ThirdwebProvider
component to start using the SDK.
import { ThirdwebProvider } from "@thirdweb-dev/react";
const App = () => {
return (
<ThirdwebProvider activeChain="ethereum" clientId="your-client-id">
<YourApp />
</ThirdwebProvider>
);
};
Examples of where to set this up: Create React App • Next.js • Vite
With the provider set up, all of the SDK’s hooks and components work out of the box!
Now you can connect to the user’s wallet and start calling functions on your smart contracts like so:
import { Web3Button } from "@thirdweb-dev/react";
const Home = () => {
return (
<Web3Button
contractAddress="{{contract_address}}"
action={async (contract) => contract.call("myFunctionName")}
>
Call myFunctionName from the connected wallet
</Web3Button>
);
};