***
title: React Native
slug: integration/mobile/react-native
subtitle: Seamless Transak integration for React Native applications
--------------------------------------------------------------------
The Transak React Native integration allows you to embed a fully functional interface directly into your React Native application.
Google Pay works only with the Transak React Native SDK integration for mobile applications.
## Integration Methods
### Transak React Native SDK (Recommended)
Official Transak SDK with built-in event handling, callbacks, and simplified camera permissions for both Expo and Non-Expo implementations.
Install the Transak SDK based on your project setup.
Install the React Native SDK:
```bash
npm i @transak/ui-react-native-sdk
```
Install required peer dependencies:
```bash
npm i react-native-webview
npm i react-native-inappbrowser-reborn
npm i @react-native-community/netinfo
```
Install the Expo SDK:
```bash
npm i @transak/ui-expo-sdk
```
Install required peer dependencies:
```bash
npm i react-native-webview
npm i expo-web-browser
npm i @react-native-community/netinfo
```
Add required camera and media permissions for KYC verification in Android and iOS.
```xml title="Android (AndroidManifest.xml)"
```
```xml title="iOS (Info.plist)"
NSCameraUsageDescription
Camera Access
NSLocationWhenInUseUsageDescription
Location Access
NSMicrophoneUsageDescription
Mic Access
NSPhotoLibraryUsageDescription
Photo Library Access
```
Add the TransakWebView component to your app with event handling.
```typescript title="React Native (without Expo)"
import {
TransakWebView,
Events,
TransakConfig,
OnTransakEvent,
} from '@transak/ui-react-native-sdk';
function TransakWebViewIntegration() {
const transakConfig: TransakConfig = {
widgetUrl: "https://global-stg.transak.com?apiKey=YOUR_API_KEY&sessionId="
};
const onTransakEventHandler: OnTransakEvent = (event, data) => {
switch (event) {
case Events.TRANSAK_WIDGET_INITIALISED:
console.log('Widget initialized:', event, data);
break;
case Events.TRANSAK_ORDER_CREATED:
console.log('Order created:', event, data);
break;
case Events.TRANSAK_ORDER_SUCCESSFUL:
console.log('Order successful:', event, data);
break;
case Events.TRANSAK_ORDER_FAILED:
console.log('Order failed:', event, data);
break;
case Events.TRANSAK_WIDGET_CLOSE:
console.log('Widget closed:', event, data);
break;
default:
console.log('Widget event:', event, data);
}
};
return (
);
}
```
```typescript title="React Native (with Expo)"
import {
TransakWebView,
Events,
TransakConfig,
OnTransakEvent,
} from '@transak/ui-expo-sdk';
function TransakWebViewIntegration() {
const transakConfig: TransakConfig = {
widgetUrl: "https://global-stg.transak.com?apiKey=YOUR_API_KEY&sessionId="
};
const onTransakEventHandler: OnTransakEvent = (event, data) => {
switch (event) {
case Events.TRANSAK_WIDGET_INITIALISED:
console.log('Widget initialized:', event, data);
break;
case Events.TRANSAK_ORDER_CREATED:
console.log('Order created:', event, data);
break;
case Events.TRANSAK_ORDER_SUCCESSFUL:
console.log('Order successful:', event, data);
break;
case Events.TRANSAK_ORDER_FAILED:
console.log('Order failed:', event, data);
break;
case Events.TRANSAK_WIDGET_CLOSE:
console.log('Widget closed:', event, data);
break;
default:
console.log('Widget event:', event, data);
}
};
return (
);
}
```
Call the [Create Widget URL](/api/public/create-widget-url) to generate a Widget URL by securely passing the [widget parameters](/customization/query-parameters).
The response returns a `widgetUrl` that should be used in the `transakConfig` prop.
A `widgetUrl` is valid for 5 minutes and can only be used once. A new `widgetUrl` must be generated for every user flow.
**Example Request:**
```bash
curl --request POST \
--url https://api-gateway-stg.transak.com/api/v2/auth/session \
--header 'access-token: YOUR_ACCESS_TOKEN' \
--header 'content-type: application/json' \
--data '{
"widgetParams": {
"apiKey": "YOUR_API_KEY",
"referrerDomain": "yourdomain.com"
}
}'
```
#### Component Props
|
Prop
|
Description
|
transakConfig
|
Supports widgetUrl and referrer as mandatory parameters
|
onTransakEvent
|
Callback function to listen to widget events
|
#### Supported Events
|
Event Name
|
Description
|
TRANSAK_WIDGET_INITIALISED
|
Widget initialised with query params
|
TRANSAK_ORDER_CREATED
|
Order created by user
|
TRANSAK_ORDER_SUCCESSFUL
|
Order is successful
|
TRANSAK_ORDER_CANCELLED
|
Order is cancelled
|
TRANSAK_ORDER_FAILED
|
Order is failed
|
TRANSAK_WALLET_REDIRECTION
|
Widget is about to redirect to passed URL
|
TRANSAK_WIDGET_CLOSE
|
Widget is about to close
|
### React Native WebView
For teams that prefer managing the WebView directly, you can use the `react-native-webview` library.
Add required camera and media permissions for KYC verification in Android and iOS.
```xml title="Android (AndroidManifest.xml)"
```
```xml title="iOS (Info.plist)"
NSCameraUsageDescription
Camera Access
NSLocationWhenInUseUsageDescription
Location Access
NSMicrophoneUsageDescription
Mic Access
NSPhotoLibraryUsageDescription
Photo Library Access
```
Install the WebView package:
```bash
npm i react-native-webview
```
Import and render the WebView with the Transak widget URL:
```javascript
import { WebView } from 'react-native-webview';
&sessionId=' }}
enableApplePay
allowsInlineMediaPlayback
mediaPlaybackRequiresUserAction={false}
/>
```
These props should not be passed for Apple Pay to function properly.
-
`sharedCookiesEnabled`
-
`injectedJavaScript`
-
`injectedJavaScriptBeforeContentLoaded`
Call the [Create Widget URL](/api/public/create-widget-url) to generate a Widget URL by securely passing the [widget parameters](/customization/query-parameters).
The response returns a `widgetUrl` that should be used as the source URL in the WebView.
A `widgetUrl` is valid for 5 minutes and can only be used once. A new `widgetUrl` must be generated for every user flow.
**Example Request:**
```bash
curl --request POST \
--url https://api-gateway-stg.transak.com/api/v2/auth/session \
--header 'access-token: YOUR_ACCESS_TOKEN' \
--header 'content-type: application/json' \
--data '{
"widgetParams": {
"apiKey": "YOUR_API_KEY",
"referrerDomain": "yourdomain.com"
}
}'
```