A comprehensive offline-first todo application built with React Native and Expo, demonstrating multiple local database solutions and network status monitoring.
This application showcases an offline-first approach to mobile development, implementing two different local database solutions (Realm and SQLite) alongside real-time network connectivity monitoring. The app provides a complete CRUD (Create, Read, Update, Delete) interface for managing todo items with full offline functionality.
- React Native with Expo SDK 53
- TypeScript for type safety
- React Navigation for tab-based navigation
- @react-native-community/netinfo for network status monitoring
The app implements two separate local database solutions:
- Library:
realm
and@realm/react
- Features:
- Object-oriented database with automatic schema management
- Real-time data synchronization
- UUID-based primary keys
- Automatic indexing for performance
- Built-in data validation
- Library:
expo-sqlite
- Features:
- Traditional SQL database with full CRUD operations
- Custom SQLiteService class for database management
- Manual schema creation and management
- Integer-based auto-incrementing primary keys
- Library:
@react-native-community/netinfo
- Features:
- Real-time network connectivity status
- Network type detection (WiFi, Cellular, etc.)
- Visual indicators in app headers
- Context-based network status sharing
- โ Create new todo items with title and description
- โ Read todo lists with real-time updates
- โ Update existing todos (edit title/description, toggle completion)
- โ Delete todos with confirmation
- โ Toggle completion status with visual indicators
- โ Pull-to-refresh functionality for data reloading
- ๐ Full offline functionality - all operations work without internet
- ๐ Dual database support - compare Realm vs SQLite performance
- ๐ Real-time synchronization - automatic updates across components
- ๐ฑ Native performance - optimized for mobile devices
- ๐จ Modern UI with custom components and styling
- ๐ฑ Responsive design for different screen sizes
- ๐ Loading states with activity indicators
- ๐ Form validation with error handling
- ๐ฏ Intuitive navigation with tab-based interface
- ๐ Real-time network monitoring
- ๐ข Visual status indicators (green/red dots)
- ๐ก Network type display (WiFi, Cellular, etc.)
- ๐ Header-based status in both database sections
expo-offline-app/
โโโ App.tsx # Main app with providers
โโโ components/
โ โโโ realm/ # Realm-specific components
โ โ โโโ TodoForm.tsx # Create/edit todo form
โ โ โโโ TodoItem.tsx # Individual todo item
โ โ โโโ TodoList.tsx # Todo list with pull-to-refresh
โ โโโ sqlite/ # SQLite-specific components
โ โ โโโ TodoForm.tsx # Create/edit todo form
โ โ โโโ TodoItem.tsx # Individual todo item
โ โ โโโ TodoList.tsx # Todo list with pull-to-refresh
โ โโโ NetInfoIndicator.tsx # Network status indicator
โ โโโ CustomButton.tsx # Reusable button component
โ โโโ ScreenWrapper.tsx # Screen layout wrapper
โโโ screens/
โ โโโ RealmScreen.tsx # Main Realm todo screen
โ โโโ SQLScreen.tsx # Main SQLite todo screen
โ โโโ EditRealmScreen.tsx # Edit Realm todo screen
โ โโโ EditSQLScreen.tsx # Edit SQLite todo screen
โโโ services/
โ โโโ task.ts # Realm Task model
โ โโโ sqlite.ts # SQLite service class
โโโ context/
โ โโโ net-info-context.tsx # Network info context
โโโ hooks/
โ โโโ useNetworkStatus.ts # Network status hook
โโโ navigation/
โ โโโ AppNavigator.tsx # Main navigation setup
โ โโโ routes.ts # Route constants
โโโ types/
โโโ types.ts # Shared type definitions
โโโ navigation.ts # Navigation type definitions
- Object-Oriented Data Model: Task class with UUID primary keys
- Real-time Queries: Automatic UI updates when data changes
- Schema Management: Automatic schema validation and migration
- Performance Optimization: Indexed fields for faster queries
- Type Safety: Full TypeScript integration
- Custom Service Layer: SQLiteService class for database operations
- Manual Schema Management: Explicit table creation and management
- CRUD Operations: Complete Create, Read, Update, Delete functionality
- Error Handling: Comprehensive error handling and user feedback
- Data Transformation: Automatic date formatting and type conversion
- Real-time Status: Live network connectivity monitoring
- Visual Indicators: Color-coded status dots (green/red)
- Network Type Detection: WiFi, Cellular, and other connection types
- Context Integration: Global network status sharing
- Header Integration: Status display in app navigation headers
- Dual Interface: Separate tabs for Realm and SQLite databases
- Modal Editing: Full-screen edit forms for todo modification
- Pull-to-Refresh: Swipe down to reload data
- Loading States: Activity indicators during data operations
- Error Handling: User-friendly error messages and alerts
- Responsive Design: Works on different screen sizes
- Realm: Uses
@realm/react
for reactive data binding - SQLite: Custom service layer with
expo-sqlite
- Data Synchronization: Real-time updates across components
- Error Recovery: Graceful handling of database errors
- Context Provider: Global network status sharing
- Custom Hook:
useNetworkStatus
for easy access - Visual Feedback: Real-time status indicators
- Type Safety: Full TypeScript integration
- Tab Navigation: Bottom tabs for database selection
- Stack Navigation: Nested stacks for each database
- Modal Presentation: Edit screens as modals
- Type Safety: Fully typed navigation parameters
- Offline-First: All operations work without internet
- Real-time Updates: Automatic UI synchronization
- Optimized Queries: Indexed fields for better performance
- Memory Management: Efficient data loading and caching
- Error Recovery: Graceful handling of network/database issues
-
Install Dependencies:
npm install
-
Start Development Server:
npx expo start
-
Run on Device/Simulator:
npx expo run:ios # or npx expo run:android
- โ iOS: Full support with native SQLite and Realm
- โ Android: Full support with native SQLite and Realm
- ๐ Web: Limited support (SQLite not available on web)
This application demonstrates:
- Offline-First Development: Building apps that work without internet
- Multiple Database Solutions: Comparing different local storage approaches
- Real-time Network Monitoring: Implementing network status awareness
- Modern React Native Patterns: Context, hooks, and TypeScript
- Mobile-First Design: Optimized UI/UX for mobile devices
- Data Synchronization: Sync local data with remote servers
- Conflict Resolution: Handle data conflicts when online
- Advanced Queries: Complex filtering and sorting
- Data Export: Export todos to various formats
- Cloud Backup: Automatic backup to cloud storage