Examples
Expo + SWR Example
This example shows the bare minimum configuration to get WunderGraph up and running with React Native, using Expo and SWR .
Important
Package exports
React Native doesn't support the new Node.js exports field yet. Add this configuration in metro.config.js
to rewrite the paths and make sure WunderGraph is imported correctly.
Fetch Api
React Native doesn't fully support the fetch api and therefor isn't fully compatible with our TypeScript client at the moment. To get around this, you can install the following polyfill.
And import it somewhere in your project, for example in App.tsx
.
Subscriptions
Subscriptions aren't supported by default either, since web streams and SSE aren't supported in React Native. You can also install a polyfill for this to make it work. Please note this is still experimental and we would love to get your feedback on this.
And import it somewhere in your project, for example in App.tsx
.
Data source configuration
As the data source, we add a single API, the SpaceX GraphQL API in this case.
Operation configuration
Next, we configure a simple Operation.
Running the application
Now, we can run the application using npm run start
, this will start WunderGraph and Expo. Use the Expo CLI to choose which device you want to run the app on.