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.js
in your project, you can create one by running:Then, you need to add 2 properties to the metro resolver:
unstable_enablePackageExports
andunstable_conditionNames
. This is to tell metro to resolve namedexports
properly.Without
expo-router
Simply import the package in the entrypoint of your app before any other import. This will polyfill all the required functionality needed.
With
expo-router
If you're using
expo-router
, you need to polyfill before the router entry:1. create a
index.js
Create an
index.js
file 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.json
Now you can replace
expo-router/entry
with./index.js
as your main entrypoint.You can run the development build using the Expo CLI, note that this needs to use the 'development build' option and not Expo Go.
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
thirdweb
package 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: