Installation
To install the React Native SDK, you'll need to install the @thirdweb/react-native-adapter package from npm on top of the thirdweb package.
Install the packages
Using your favorite package manager or expo, install all the require dependencies
Since react native requires installing native dependencies directly, you also have to install these required peer dependencies:
Here's an explanation of each peer dependency and why its needed:
Edit your `metro.config.js`
If you don't already have a
metro.config.file.jsin your project, you can create one by running:Then, you need to add 2 properties to the metro resolver:
unstable_enablePackageExportsandunstable_conditionNames. This is to tell metro to resolve namedexportsproperly.Import `@thirdweb-dev/react-native-adapter`
Without
expo-routerSimply import the package in the entrypoint of your app before any other import. This will polyfill all the required functionality needed.
With
expo-routerIf you're using
expo-router, you need to polyfill before the router entry:1. create a
app/index.tsThis will be the new entrypoint to your app, ensuring the polyfills happen before any routing.
2. Change your main entrypoint in
package.jsonNow you can replace
expo-router/entrywith./app/indexas your main entrypoint.Use the `thirdweb` package normally
Once all the setup above is all done, you can use the most of functionality in the
thirdwebpackage out of the box, without having to do any react native specific code.This means that you can follow all the React documentation and expect it all to be exactly the same.
Examples:
Working demo
If you want to see a fully working demo of the thirdweb package in a React Native app, you can check out the expo-starter repo.