Expo SDK
The LiveI18n Expo SDK provides seamless integration with Expo applications, featuring optimized mobile caching with AsyncStorage persistence and automatic locale detection.
Overviewβ
The Expo SDK is designed specifically for Expo applications with features tailored to the Expo ecosystem:
Key Featuresβ
- π Hybrid Caching: Fast in-memory LRU cache + AsyncStorage persistence
- π± Mobile Optimized: Automatic locale detection using device settings
- β‘ Zero Config: Works out of the box with sensible defaults
- π§ TypeScript: Full TypeScript support with complete type definitions
- π Expo Compatible: Fully compatible with Expo managed and bare workflows
- πΎ Offline Ready: Persistent cache survives app restarts
Performanceβ
- Memory Cache: < 1ms response time for cached translations
- AsyncStorage Cache: ~5ms response time for persistent cache hits
- Network Requests: 100-500ms for new translations
- Cache Size: 500 entries by default (customizable), 1-hour TTL by default (customizable)
- Preload: Up to 50 cached entries loaded on app startup
Quick Startβ
Installationβ
npm install @livei18n/react-native-expo-sdk
Basic Setupβ
import React from 'react';
import { View, Text, Button } from 'react-native';
import { LiveText, LiveI18nProvider, useLiveI18n } from '@livei18n/react-native-expo-sdk';
function DemoContent() {
const { updateDefaultLanguage } = useLiveI18n();
const changeLanguage = (language: string) => {
updateDefaultLanguage(language);
};
return (
<View style={{ flex: 1, padding: 20 }}>
<Text style={{ fontSize: 24, marginBottom: 20 }}>
<LiveText context="greeting" tone="friendly">
Welcome to our Expo app!
</LiveText>
</Text>
<Button title="EspaΓ±ol" onPress={() => changeLanguage('es-ES')} />
<Button title="FranΓ§ais" onPress={() => changeLanguage('fr-FR')} />
<Button title="English" onPress={() => changeLanguage('en-US')} />
</View>
);
}
export default function App() {
return (
<LiveI18nProvider config={{
apiKey: 'your-api-key',
customerId: 'your-customer-id'
}}>
<DemoContent />
</LiveI18nProvider>
);
}
Core Conceptsβ
LiveText Componentβ
The <LiveText> component automatically translates its children:
<LiveText>Hello World</LiveText>
<LiveText context="navigation">Home</LiveText>
<LiveText tone="formal" context="business">Welcome</LiveText>
Global Language Managementβ
Update the default language for the entire app using the hook:
import { useLiveI18n } from '@livei18n/react-native-expo-sdk';
function LanguageSettings() {
const { updateDefaultLanguage, defaultLanguage } = useLiveI18n();
// Change language globally
const changeLanguage = (language: string) => {
updateDefaultLanguage(language);
};
return (
<Text>Current language: {defaultLanguage}</Text>
);
}
Architectureβ
The Expo SDK uses a hybrid caching architecture optimized for Expo applications:
βββββββββββββββββββββββββββββββββββββββ
β Expo App β
β β
β βββββββββββββββββββββββββββββββ β
β β LiveText β β
β β Components β β
β βββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββββββββββββββ β
β β LiveI18n SDK β β
β β β β
β β Memory Cache (LRU) β β
β β ββ 500 entries β β
β β ββ 1-hour TTL β β
β β ββ < 1ms access β β
β β β β
β β AsyncStorage Cache β β
β β ββ Persistent storage β β
β β ββ Survives app restart β β
β β ββ ~5ms access β β
β β ββ Auto-sync with memory β β
β βββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββ
β
βΌ HTTPS
βββββββββββββββββββββββββββββββββββββββ
β LiveI18n API β
β β
β Redis Cache (24-hour TTL) β
β AI Translation Service β
βββββββββββββββββββββββββββββββββββββββ
Next Stepsβ
- Installation Guide - Detailed setup instructions
- Basic Usage - Learn the fundamentals
- Configure caching - Performance optimization
- Try the Expo demo - Complete working example
Need Help?β
- Check our best practices guide
- Try the Expo demo
- Join our Discord community