|
1 | | -# react-native-managed-template |
| 1 | +# React Native Managed Template |
2 | 2 |
|
3 | | -A React Native Expo starter template project with built-in navigation with `expo-router` & state management with `zustand`. |
| 3 | +A production-ready React Native Expo starter template with authentication flow, navigation, state management, and modern development tools pre-configured. |
4 | 4 |
|
5 | | -## What's included? |
| 5 | +## ✨ Features |
6 | 6 |
|
7 | | -- Navigation with Expo Router |
8 | | -- Axios with Interceptors |
9 | | -- Zustand for Global State Management |
10 | | -- Unistyles v3 for Styling |
11 | | -- VS Code snippets for Screens and Components |
12 | | -- Custom Fonts |
13 | | -- Utility Functions and Configs |
| 7 | +### Core Features |
14 | 8 |
|
15 | | -## Why should I use this template? |
| 9 | +- 🚀 **Expo SDK 54** - Latest Expo framework with managed workflow |
| 10 | +- 📱 **Expo Router** - File-based routing with native navigation |
| 11 | +- 🎨 **Unistyles v3** - Universal styling system with theme support |
| 12 | +- 🗄️ **Zustand** - Lightweight state management |
| 13 | +- 🌐 **Axios** - HTTP client with interceptors pre-configured |
| 14 | +- 🔐 **Expo Secure Store** - Secure storage for sensitive data |
| 15 | +- 🎭 **Dark/Light Theme** - Built-in theme switching with context |
16 | 16 |
|
17 | | -- Splash Screen & Authentication flow |
18 | | -- Light & Dark Themes |
19 | | -- Styled Components |
20 | | -- Pre-setup navigation and zustand |
21 | | -- Eslint & Prettier preconfigured to work together |
22 | | -- Actively maintained |
| 17 | +### Authentication & Navigation |
| 18 | + |
| 19 | +- ✅ Pre-built authentication flow |
| 20 | +- 🔒 Protected routes with auth guards |
| 21 | +- 📍 Deep linking support |
| 22 | +- 🎯 Type-safe navigation with TypeScript |
| 23 | + |
| 24 | +### Development Experience |
| 25 | + |
| 26 | +- 💅 **ESLint & Prettier** - Code quality and formatting |
| 27 | +- 📝 **TypeScript** - Full type safety |
| 28 | +- 🎨 **Custom Fonts** - Pre-configured font loading |
| 29 | +- 🧩 **VS Code Snippets** - Speed up development |
| 30 | +- 🍞 **Toast Notifications** - User feedback system |
| 31 | +- ⌨️ **Keyboard Controller** - Enhanced keyboard handling |
| 32 | +- 🎬 **Reanimated** - Smooth animations |
| 33 | + |
| 34 | +### Build & Deployment |
| 35 | + |
| 36 | +- 🏗️ **EAS Build** - Production-ready build profiles |
| 37 | +- 🔧 **Development Client** - Custom dev builds |
| 38 | +- 📦 **Prebuild** - Native project generation |
| 39 | + |
| 40 | +## 📋 Prerequisites |
| 41 | + |
| 42 | +- Node.js (v18 or newer) |
| 43 | +- npm or yarn |
| 44 | +- [Expo CLI](https://docs.expo.dev/get-started/installation/) |
| 45 | +- For iOS development: macOS with Xcode |
| 46 | +- For Android development: Android Studio |
| 47 | + |
| 48 | +## 🚀 Getting Started |
| 49 | + |
| 50 | +### 1. Clone or use this template |
| 51 | + |
| 52 | +```bash |
| 53 | +# Clone the repository |
| 54 | +git clone <repository-url> |
| 55 | +cd react-native-managed-template |
| 56 | + |
| 57 | +# Or use as template in GitHub |
| 58 | +``` |
| 59 | + |
| 60 | +### 2. Install dependencies |
| 61 | + |
| 62 | +```bash |
| 63 | +npm install |
| 64 | +# or |
| 65 | +yarn install |
| 66 | +``` |
| 67 | + |
| 68 | +### 3. Start development server |
| 69 | + |
| 70 | +```bash |
| 71 | +npm start |
| 72 | +# or |
| 73 | +expo start |
| 74 | +``` |
| 75 | + |
| 76 | +### 4. Run on device/simulator |
| 77 | + |
| 78 | +```bash |
| 79 | +# Run on iOS simulator |
| 80 | +npm run ios |
| 81 | + |
| 82 | +# Run on Android emulator |
| 83 | +npm run android |
| 84 | + |
| 85 | +# Or scan QR code with Expo Go app |
| 86 | +``` |
| 87 | + |
| 88 | +## 📁 Project Structure |
| 89 | + |
| 90 | +``` |
| 91 | +react-native-managed-template/ |
| 92 | +├── app/ # Expo Router pages |
| 93 | +│ ├── _layout.tsx # Root layout |
| 94 | +│ ├── sign-in.tsx # Sign in screen |
| 95 | +│ └── (protected)/ # Protected routes group |
| 96 | +│ ├── _layout.tsx |
| 97 | +│ ├── index.tsx # Home screen |
| 98 | +│ └── profile.tsx # Profile screen |
| 99 | +├── src/ |
| 100 | +│ ├── components/ # Reusable components |
| 101 | +│ │ ├── styled/ # Styled UI components |
| 102 | +│ │ └── Profile/ # Feature-specific components |
| 103 | +│ ├── contexts/ # React contexts |
| 104 | +│ │ ├── auth.context.tsx # Authentication context |
| 105 | +│ │ └── theme.context.tsx # Theme management |
| 106 | +│ ├── hooks/ # Custom React hooks |
| 107 | +│ ├── lib/ # Utilities and configs |
| 108 | +│ │ ├── axios.ts # Axios instance & interceptors |
| 109 | +│ │ ├── secure-store.ts # Secure storage wrapper |
| 110 | +│ │ └── date-time.ts # Date utilities |
| 111 | +│ ├── store/ # Zustand stores |
| 112 | +│ ├── unistyles/ # Theme tokens & styles |
| 113 | +│ └── constants/ # App constants |
| 114 | +├── assets/ # Static assets |
| 115 | +│ ├── fonts/ |
| 116 | +│ ├── icons/ |
| 117 | +│ └── images/ |
| 118 | +├── android/ # Android native code |
| 119 | +├── ios/ # iOS native code |
| 120 | +└── app.config.ts # Expo app configuration |
| 121 | +``` |
| 122 | + |
| 123 | +## 🧩 VS Code Snippets |
| 124 | + |
| 125 | +The template includes pre-built VS Code snippets to accelerate development. These snippets generate boilerplate code with best practices baked in. |
| 126 | + |
| 127 | +### Available Snippets |
| 128 | + |
| 129 | +#### Component Snippet (`rnbc`) |
| 130 | + |
| 131 | +Type `rnbc` to generate a new React Native component with: |
| 132 | + |
| 133 | +- Proper imports (StyledText, React, View) |
| 134 | +- Unistyles setup with theme tokens |
| 135 | +- Component structure with default styling |
| 136 | + |
| 137 | +```typescript |
| 138 | +// Generated code structure: |
| 139 | +import { StyledText } from '@/components/styled/StyledText'; |
| 140 | +import React from 'react'; |
| 141 | +import { View } from 'react-native'; |
| 142 | +import { StyleSheet } from 'react-native-unistyles'; |
| 143 | + |
| 144 | +const MyComponent = () => { |
| 145 | + return ( |
| 146 | + <View style={styles.container}> |
| 147 | + <StyledText style={styles.text}>MyComponent</StyledText> |
| 148 | + </View> |
| 149 | + ); |
| 150 | +}; |
| 151 | + |
| 152 | +const styles = StyleSheet.create(({ spacings }) => ({ |
| 153 | + container: { |
| 154 | + padding: spacings.sm, |
| 155 | + }, |
| 156 | + text: { |
| 157 | + textDecorationLine: 'underline' |
| 158 | + }, |
| 159 | +})); |
| 160 | + |
| 161 | +export default MyComponent; |
| 162 | +``` |
| 163 | + |
| 164 | +#### Screen Snippet (`rnbs`) |
| 165 | + |
| 166 | +Type `rnbs` to generate a new screen with: |
| 167 | + |
| 168 | +- ScrollView with keyboard handling |
| 169 | +- Expo Router integration |
| 170 | +- Safe area insets |
| 171 | +- Responsive padding using theme tokens |
| 172 | + |
| 173 | +```typescript |
| 174 | +// Generated code structure: |
| 175 | +import { StyledText } from '@/components/styled/StyledText'; |
| 176 | +import { useRouter } from 'expo-router'; |
| 177 | +import React from 'react'; |
| 178 | +import { ScrollView } from 'react-native'; |
| 179 | +import { StyleSheet } from 'react-native-unistyles'; |
| 180 | + |
| 181 | +const MyScreen = () => { |
| 182 | + const router = useRouter(); |
| 183 | + |
| 184 | + return ( |
| 185 | + <ScrollView |
| 186 | + keyboardShouldPersistTaps='handled' |
| 187 | + showsVerticalScrollIndicator={false} |
| 188 | + contentContainerStyle={styles.contentContainer}> |
| 189 | + <StyledText variant='title'>MyScreen</StyledText> |
| 190 | + </ScrollView> |
| 191 | + ); |
| 192 | +}; |
| 193 | + |
| 194 | +const styles = StyleSheet.create(({ spacings }, rt) => ({ |
| 195 | + contentContainer: { |
| 196 | + flexGrow: 1, |
| 197 | + paddingHorizontal: spacings.base, |
| 198 | + paddingBottom: spacings.xxxl, |
| 199 | + paddingTop: rt.insets.top + spacings.base, |
| 200 | + }, |
| 201 | +})); |
| 202 | + |
| 203 | +export default MyScreen; |
| 204 | +``` |
| 205 | + |
| 206 | +### How to Use Snippets |
| 207 | + |
| 208 | +1. Create a new `.tsx` file in your project |
| 209 | +2. Type the snippet prefix (`rnbc` or `rnbs`) |
| 210 | +3. Press `Tab` or `Enter` to expand |
| 211 | +4. The component/screen name will be auto-selected - just type your desired name |
| 212 | +5. Press `Tab` to move to the next placeholder (if any) |
| 213 | + |
| 214 | +These snippets ensure consistency across your codebase and save time on repetitive boilerplate code. |
| 215 | + |
| 216 | +## 🔐 Authentication Flow |
| 217 | + |
| 218 | +The template includes a complete authentication flow: |
| 219 | + |
| 220 | +1. **Sign In Screen** - Entry point for unauthenticated users |
| 221 | +2. **Auth Context** - Manages authentication state |
| 222 | +3. **Protected Routes** - Automatically guards routes requiring authentication |
| 223 | +4. **Secure Storage** - Persists tokens securely |
| 224 | + |
| 225 | +## 📦 Available Scripts |
| 226 | + |
| 227 | +```bash |
| 228 | +# Development |
| 229 | +npm start # Start Expo development server |
| 230 | +npm run android # Run on Android |
| 231 | +npm run ios # Run on iOS |
| 232 | + |
| 233 | +# Code Quality |
| 234 | +npm run lint # Run ESLint with auto-fix |
| 235 | + |
| 236 | +# Build |
| 237 | +npm run prebuild # Generate native projects |
| 238 | +npm run build:dev # Build development client locally |
| 239 | +npm run build:prev # Build preview build locally |
| 240 | +npm run build:prod # Build production build locally |
| 241 | +``` |
| 242 | + |
| 243 | +## 🛠️ Built With |
| 244 | + |
| 245 | +- [Expo](https://expo.dev/) - Framework and platform |
| 246 | +- [Expo Router](https://docs.expo.dev/router/introduction/) - File-based routing |
| 247 | +- [React Native](https://reactnative.dev/) - Mobile framework |
| 248 | +- [TypeScript](https://www.typescriptlang.org/) - Type safety |
| 249 | +- [Zustand](https://zustand-demo.pmnd.rs/) - State management |
| 250 | +- [Unistyles](https://reactnativeunistyles.vercel.app/) - Styling solution |
| 251 | +- [Axios](https://axios-http.com/) - HTTP client |
| 252 | +- [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/) - Animations |
| 253 | +- [React Native Toast Message](https://github.com/calintamas/react-native-toast-message) - Notifications |
| 254 | + |
| 255 | +## 📝 Configuration |
| 256 | + |
| 257 | +### App Configuration |
| 258 | + |
| 259 | +Update [app.config.ts](app.config.ts) with your app details: |
| 260 | + |
| 261 | +```typescript |
| 262 | +export default { |
| 263 | + name: 'Your App Name', |
| 264 | + slug: 'your-app-slug', |
| 265 | + // ... other configurations |
| 266 | +}; |
| 267 | +``` |
| 268 | + |
| 269 | +### Environment Variables |
| 270 | + |
| 271 | +Create a `.env` file for environment-specific variables (not included in repo): |
| 272 | + |
| 273 | +```env |
| 274 | +API_BASE_URL=https://your-api.com |
| 275 | +``` |
| 276 | + |
| 277 | +### Navigation Theme |
| 278 | + |
| 279 | +Customize navigation appearance in [src/hooks/useNavigationTheme.ts](src/hooks/useNavigationTheme.ts) |
| 280 | + |
| 281 | +## 🚢 Deployment |
| 282 | + |
| 283 | +### Building for Production |
| 284 | + |
| 285 | +1. **Configure EAS** |
| 286 | + |
| 287 | + ```bash |
| 288 | + eas build:configure |
| 289 | + ``` |
| 290 | + |
| 291 | +2. **Build for Android/iOS** |
| 292 | + |
| 293 | + ```bash |
| 294 | + eas build --platform android |
| 295 | + eas build --platform ios |
| 296 | + ``` |
| 297 | + |
| 298 | +3. **Submit to Stores** |
| 299 | + ```bash |
| 300 | + eas submit --platform android |
| 301 | + eas submit --platform ios |
| 302 | + ``` |
| 303 | + |
| 304 | +## 🤝 Contributing |
| 305 | + |
| 306 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 307 | + |
| 308 | +## 📄 License |
| 309 | + |
| 310 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 311 | + |
| 312 | +## 🙏 Acknowledgments |
| 313 | + |
| 314 | +- Expo team for the amazing framework |
| 315 | +- React Native community for the excellent libraries |
| 316 | +- All testers who help improve this template |
| 317 | + |
| 318 | +## 📧 Support |
| 319 | + |
| 320 | +If you have any questions or run into issues, please open an issue on GitHub. |
| 321 | + |
| 322 | +--- |
| 323 | + |
| 324 | +Made with ❤️ for the React Native community |
0 commit comments