Introduction
Integrating Web3 into a React Native app sounds daunting, but with Thirdweb it becomes surprisingly manageable. During my time at LadderIt, I helped build a loyalty app where users earn blockchain-backed rewards — here's what I learned.
Setting Up Thirdweb
First, install the SDK:
npx expo install @thirdweb-dev/react-native @thirdweb-dev/react-native-compat
Wrap your app with the ThirdwebProvider:
import { ThirdwebProvider } from "@thirdweb-dev/react-native";
export default function App() {
return (
<ThirdwebProvider activeChain="polygon">
<YourApp />
</ThirdwebProvider>
);
}
Wallet Connection
The `useConnect` hook handles wallet connection with minimal setup:
const { connect } = useConnect();
const handleConnect = async () => {
await connect(metamaskWallet(), {
chainId: 137, // Polygon
});
};