Getting Started
We recommend starting a new thirdweb React Native project using our CLI, which sets up everything automatically for you.
In your CLI, run:
or clone the expo-starter repo using git.
To manually install the React Native SDK, you'll need to install the @thirdweb/react-native-adapter package from npm on top of the thirdweb package.
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:
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.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
index.jsCreate an
index.jsfile at the root of the repo. This 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./index.jsas your main entrypoint.Additional notes
react-native-aes-gcm-cryptorequiresminSDK 26for android, you can edit this in yourapp.jsonfile.- You will get some warnings about unresolved exports, this is normal and will get better as the libraries get updated.
You can run the development build using the Expo CLI, note that this needs to use the 'development build' option and not Expo Go.
Expo Go
Due to conflicts between Expo Go's wrapper and thirdweb's, Expo Go is not currently supported. When running your app, be sure to run a normal development build without using Expo Go.
If the Expo CLI says "Using Expo Go" when starting the app, press
sto switch to the development build.
Prebuild the app (only needed once):
Run the development build on ios:
Run the development build on android:
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: