DEV Community

Laxman Nemane
Laxman Nemane

Posted on

πŸ“‚ React Native CLI Folder Structure – Best Practices πŸš€

When working with React Native CLI, having a well-structured project is key to scalability, maintainability, and efficiency. Below is an ideal folder structure along with comments explaining each folder's purpose to keep your project clean and organized!

🚨 Note: Everyone has their own coding style, and following this structure is not mandatory. It’s just a guideline to help you organize your project better!

πŸ“Œ Recommended Folder Structure

πŸ“‚ YourProjectName
 ┣ πŸ“‚ android/              # ⚠️ Native Android code (Java/Kotlin) – DO NOT modify unless necessary!
 ┣ πŸ“‚ ios/                  # ⚠️ Native iOS code (Swift/Objective-C) – DO NOT modify unless necessary!
 ┣ πŸ“‚ src/                  # Main source code
 ┃ ┣ πŸ“‚ assets/             # πŸ“‚ Stores images, fonts, icons, etc.
 ┃ ┣ πŸ“‚ components/         # πŸ“‚ Reusable UI components (Button, Card, etc.)
 ┃ ┣ πŸ“‚ screens/            # πŸ“‚ Screens (Home, Login, Profile)
 ┃ ┣ πŸ“‚ navigation/         # πŸ“‚ Navigation setup (React Navigation)
 ┃ ┣ πŸ“‚ redux/              # πŸ“‚ Redux store, slices (if using Redux)
 ┃ ┣ πŸ“‚ hooks/              # πŸ“‚ Custom hooks for reusable logic
 ┃ ┣ πŸ“‚ utils/              # πŸ“‚ Utility/helper functions (date formatting, API calls, etc.)
 ┃ ┣ πŸ“‚ constants/          # πŸ“‚ Stores app-wide constants (colors, fonts, etc.)
 ┃ ┣ πŸ“‚ services/           # πŸ“‚ API services (Axios, Firebase, etc.)
 ┃ ┣ πŸ“œ App.tsx             # 🏠 Root component
 ┃ ┣ πŸ“œ index.tsx           # πŸš€ Entry point of the app
 ┣ πŸ“œ .gitignore            # πŸ“œ Files to ignore in Git
 ┣ πŸ“œ package.json          # πŸ“œ Project dependencies
 ┣ πŸ“œ tsconfig.json         # πŸ“œ TypeScript configuration (if using TS)
 ┣ πŸ“œ babel.config.js       # πŸ“œ Babel configuration
 ┣ πŸ“œ metro.config.js       # πŸ“œ Metro bundler configuration
 ┣ πŸ“œ react-native.config.js# πŸ“œ React Native CLI configuration

Enter fullscreen mode Exit fullscreen mode

πŸ“Œ Important Guidelines
⚠️ DO NOT modify the android/ and ios/ folders unless you are working with native code (e.g., linking third-party libraries, modifying native modules, or changing build settings).

πŸ’‘ Pro Tip: Use absolute imports (@components, @screens) in your tsconfig.json to avoid messy ../../../ imports!

πŸš€ Follow this structure to make your React Native projects more organized and easier to manage! But remember, coding is all about flexibilityβ€”organize your project in a way that works best for you! Happy coding! πŸ”₯πŸ’™ #ReactNative #MobileDevelopment #BestPractices

Let’s keep learning and growing together!πŸ’–

Top comments (0)