@devtravelcode/widget-native
v1.3.5
Published
TravelCode search widget for React Native (flights, hotels)
Readme
@devtravelcode/widget-native
React Native widget for searching and booking flights and hotels. Powered by Travel-Code.com.
Prerequisites
Before installing the widget, you need to become a Travel-Code client and set up your widget:
Step 1: Register as a client
Sign up at travel-code.com and get access to the partner dashboard.
Step 2: Create and configure your widget
Go to travel-code.com/user/search-widget-options and:
- Create a new widget
- Choose which services to enable (flights, hotels)
- Customize colors, default language, and currency
- Configure commission settings
Step 3: Get your API token
After saving the widget configuration, copy the API token from the widget settings page. You will need it to initialize the widget in your app.
Installation
npm install @devtravelcode/widget-nativePeer dependencies
npx expo install react-native-gesture-handler react-native-safe-area-context \
react-native-svg react-native-reanimated react-native-maps \
react-native-webview @react-native-async-storage/async-storageUsage
import { TravelCodeWidget } from '@devtravelcode/widget-native';
export default function App() {
return (
<TravelCodeWidget
token="YOUR_API_TOKEN"
lang="en"
currency="USD"
/>
);
}Props
| Prop | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| token | string | Yes | — | API token from your widget settings |
| lang | string | No | "en" | Language ("en", "ru") |
| currency | string | No | "USD" | Currency code ("USD", "GBP", "EUR") |
| nationality | string | No | — | ISO-2 country code (e.g. "GB", "PL") prefilled into the nationality field in hotel/car search forms. Overrides the default ("GB" for hotels) and IP-based detection (for cars). The user can still change it manually. |
| config | WidgetConfig | No | — | Widget configuration (merged with remote config from server) |
| user | WidgetUser | No | — | Host-app user identity. Appended to "Buy"/"Book" URLs as clientUserId, clientEmail, clientName query params (only fields that are set). |
| showBasketButton | boolean | No | false | When true, renders a floating basket button (bottom-right). Tap opens <basket_link>/basket inside the WebView. Requires config.additional.basket_link. |
| style | StyleProp<ViewStyle> | No | — | Custom container style |
WidgetUser
type WidgetUser = {
id?: string | number;
email?: string;
name?: string;
};Example
import React from 'react';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { TravelCodeWidget } from '@devtravelcode/widget-native';
export default function App() {
return (
<SafeAreaProvider>
<TravelCodeWidget
token="your-token-here"
lang="en"
currency="USD"
nationality="GB"
user={{ id: 'u-123', email: '[email protected]', name: 'Jane Doe' }}
showBasketButton
/>
</SafeAreaProvider>
);
}In-App WebView
Booking and payment pages open inside the app in a full-screen WebView instead of redirecting to an external browser. This keeps users within your app throughout the entire booking flow (room selection, cart, payment).
The WebView screen includes:
- Back button — navigates back through WebView history, then returns to search results
- Close button — returns to search results immediately
- iOS swipe-back gesture support
This requires react-native-webview (listed as a peer dependency above).
Requirements
- React Native >= 0.72
- React >= 18
- Expo SDK 49+ (recommended)
Support
For technical support and licensing inquiries: [email protected]
For widget configuration help, visit the Travel-Code documentation.
