Clean and Scalable React Native Expo Project Structure for Modern Apps

Clean and Scalable React Native Expo Project Structure for Modern Apps

A Step-by-Step Guide to Organize and Scale Your React Native Expo Applications

ยท

6 min read

Introduction ๐Ÿš€

When building a React Native app with Expo, having a clean and scalable folder structure can make a huge difference. A well-organized project helps developers work efficiently, reduces bugs, and makes it easier to scale features in the future.

In this blog, Iโ€™ll guide you through:

  • A production-ready folder structure for React Native Expo.

  • How to organize your files and folders.

Best practices for building modern and scalable mobile apps.

Why a Clean Project Structure Matters ๐Ÿ› ๏ธ

A messy project can lead to:

  • Difficulty finding files.

  • Duplicate code and components.

  • Confusion for team members or future developers.

With a clean folder structure, you get:
โœ… Scalability: Add new features easily.
โœ… Maintainability: Manage code efficiently.
โœ… Reusability: Share components, constants, and logic.

A good folder structure saves time and makes your app development smoother!

Overview of the Folder Structure ๐Ÿ—‚๏ธ

root/
โ”œโ”€โ”€ assets/                          # Static assets like fonts, images, and icons.
โ”‚   โ”œโ”€โ”€ fonts/                       # Custom fonts (e.g., Roboto, OpenSans).
โ”‚   โ”œโ”€โ”€ images/                      # App images (e.g., product placeholders, logos).
โ”‚   โ””โ”€โ”€ icons/                       # App icons (e.g., cart, profile icons).
โ”œโ”€โ”€ src/                             # Main source folder for all app logic.
โ”‚   โ”œโ”€โ”€ app/                         # Expo Router-based file system routing.
โ”‚   โ”‚   โ”œโ”€โ”€ _layout.tsx              # Root layout wrapping navigation logic.
โ”‚   โ”‚   โ”œโ”€โ”€ index.tsx                # Home screen showing featured products.
โ”‚   โ”‚   โ”œโ”€โ”€ login/                   # Screens for user login.
โ”‚   โ”‚   โ”œโ”€โ”€ register/                # Screens for user registration.
โ”‚   โ”‚   โ”œโ”€โ”€ products/                # Routes for product listings and details.
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ _layout.tsx          # Layout wrapper for products.
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ index.tsx            # Products listing screen.
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ [productId].tsx      # Dynamic product detail page.
โ”‚   โ”‚   โ”œโ”€โ”€ cart/                    # Screens for shopping cart.
โ”‚   โ”‚   โ”œโ”€โ”€ orders/                  # User order history and details.
โ”‚   โ”‚   โ””โ”€โ”€ profile/                 # User profile and settings screens.
โ”‚   โ”œโ”€โ”€ components/                  # Reusable UI components for consistency.
โ”‚   โ”‚   โ”œโ”€โ”€ common/                  # Common components (e.g., Button, Input, Loader).
โ”‚   โ”‚   โ”œโ”€โ”€ ProductCard.tsx          # Component to display product cards in list views.
โ”‚   โ”‚   โ””โ”€โ”€ CartItem.tsx             # Component for individual cart items.
โ”‚   โ”œโ”€โ”€ constants/                   # App-wide constants for reusability.
โ”‚   โ”‚   โ”œโ”€โ”€ colors.ts                # Centralized color palette.
โ”‚   โ”‚   โ”œโ”€โ”€ routes.ts                # Route names for navigation.
โ”‚   โ”‚   โ””โ”€โ”€ messages.ts              # Static messages or text content.
โ”‚   โ”œโ”€โ”€ hooks/                       # Custom hooks for logic abstraction.
โ”‚   โ”‚   โ”œโ”€โ”€ useAuth.ts               # Hook for handling authentication.
โ”‚   โ”‚   โ””โ”€โ”€ useCart.ts               # Hook for cart-related logic.
โ”‚   โ”œโ”€โ”€ redux/                       # State management using Redux Toolkit.
โ”‚   โ”‚   โ”œโ”€โ”€ store.ts                 # Redux store configuration.
โ”‚   โ”‚   โ”œโ”€โ”€ slices/                  # Individual Redux slices for state.
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ authSlice.ts         # Auth state logic.
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ productSlice.ts      # Product state logic.
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ cartSlice.ts         # Cart state logic.
โ”‚   โ”œโ”€โ”€ services/                    # API services for network calls.
โ”‚   โ”‚   โ”œโ”€โ”€ apiClient.ts             # Axios instance with base URL.
โ”‚   โ”‚   โ”œโ”€โ”€ productService.ts        # APIs for product listings and details.
โ”‚   โ”‚   โ””โ”€โ”€ authService.ts           # APIs for login and registration.
โ”‚   โ”œโ”€โ”€ styles/                      # Global and theme-based styles.
โ”‚   โ”‚   โ”œโ”€โ”€ globalStyles.ts          # Global reusable styles.
โ”‚   โ”‚   โ””โ”€โ”€ theme.ts                 # Theme configuration (colors, fonts, spacing).
โ”‚   โ”œโ”€โ”€ types/                       # TypeScript interfaces and types.
โ”‚   โ”‚   โ”œโ”€โ”€ Product.ts               # Product type definition.
โ”‚   โ”‚   โ””โ”€โ”€ Cart.ts                  # Cart item type definition.
โ”‚   โ””โ”€โ”€ utils/                       # Utility functions for app logic.
โ”‚       โ”œโ”€โ”€ helpers.ts               # General helper functions.
โ”‚       โ””โ”€โ”€ formatCurrency.ts        # Function to format currency values.
โ”œโ”€โ”€ App.tsx                          # Entry point for the React Native app.
โ”œโ”€โ”€ package.json                     # Project dependencies and scripts.
โ””โ”€โ”€ tsconfig.json                    # TypeScript configuration file.
Folder/FileDescriptionExample Content
assets/Static resources like fonts, images, and icons.logo.png, productPlaceholder.png.
app/Expo Router-based folder for navigation and screens.products/index.tsx, cart/index.tsx.
components/Reusable UI components for buttons, inputs, cards, and lists.Button.tsx, ProductCard.tsx.
constants/Centralized app constants like colors, routes, and messages.COLORS.primary, ROUTES.PRODUCTS.
hooks/Custom hooks to abstract logic like authentication or cart management.useAuth.ts, useCart.ts
redux/State management setup using Redux Toolkit.authSlice.ts, cartSlice.ts.
services/API logic using Axios for interacting with backend services.productService.ts, authService.ts
styles/Global styles and themes for consistent UI design.globalStyles.ts, theme.ts.
types/TypeScript type definitions for API responses, components, or state.Product.ts, Cart.ts.
utils/Utility functions for formatting, validation, or common operations.formatCurrency.ts, helpers.ts

Detailed Explanation of Each Folder ๐Ÿ“„

  1. assets/ ๐ŸŽจ

    Purpose: File-based routing using Expo Router. Each folder represents a route.

โ”œโ”€โ”€ app/                         
โ”‚   โ”œโ”€โ”€ _layout.tsx        # Root layout for navigation
โ”‚   โ”œโ”€โ”€ index.tsx          # Home screen
โ”‚   โ”œโ”€โ”€ products/          # Product screens
โ”‚   โ”‚   โ”œโ”€โ”€ index.tsx      # Product list
โ”‚   โ”‚   โ””โ”€โ”€ [productId].tsx # Dynamic product details
  1. app/ ๐Ÿ“ฑ

    Purpose: File-based routing using Expo Router. Each folder represents a route.

โ”œโ”€โ”€ app/                         
โ”‚   โ”œโ”€โ”€ _layout.tsx        # Root layout for navigation
โ”‚   โ”œโ”€โ”€ index.tsx          # Home screen
โ”‚   โ”œโ”€โ”€ products/          # Product screens
โ”‚   โ”‚   โ”œโ”€โ”€ index.tsx      # Product list
โ”‚   โ”‚   โ””โ”€โ”€ [productId].tsx # Dynamic product details
  1. components/ ๐Ÿงฉ

    Purpose: Reusable UI components.

Example:

  • Button.tsx (Custom Button component).

  • ProductCard.tsx (Reusable product card component).

  1. constants/ ๐Ÿ”—

    Purpose: Centralized app constants (colors, routes, messages).

export const COLORS = {
  primary: '#3498db',
  secondary: '#2ecc71',
};
  1. hooks/ ๐ŸŽฃ

    Purpose: Custom React hooks to abstract logic.

    Example:

    • useAuth.ts (Handle user login/logout).

    • useCart.ts (Manage cart items).

  1. redux/ ๐Ÿ—„๏ธ

    Purpose: State management using Redux Toolkit.

redux/                        
โ”œโ”€โ”€ store.ts                 # Redux store
โ”œโ”€โ”€ slices/                  
โ”‚   โ”œโ”€โ”€ authSlice.ts         # Authentication state
โ”‚   โ”œโ”€โ”€ productSlice.ts      # Product state
โ”‚   โ””โ”€โ”€ cartSlice.ts         # Cart state
  1. services/ ๐Ÿ”Œ

Purpose: API services and network logic.

Example:

  • globalStyles.ts (Reusable global styles).

  • theme.ts (Colors, font sizes, spacing).

  1. types/ ๐Ÿ“

    Purpose: TypeScript types for props, state, and API responses.

export interface Product {
  id: string;
  name: string;
  price: number;
  image: string;
}
  1. utils/ ๐Ÿ› ๏ธ

Purpose: Utility functions for common tasks.

Example:

formatCurrency.ts (Format prices like $99.99).

Key Best Practices ๐Ÿ’ก

  1. Keep It Modular: Break code into reusable components.

  2. Centralize Constants: Use constants for routes, colors, and messages.

  3. State Management: Use Redux or Context API for managing app state.

  4. TypeScript: Define types for props, states, and API responses.

Clean Code: Use tools like ESLint and Prettier for consistency.

Conclusion ๐ŸŽ‰

By following this clean and scalable project structure, you can:
โœ… Build organized, maintainable apps.
โœ… Scale your app effortlessly as it grows.
โœ… Improve team collaboration and code quality.

Start implementing this in your React Native Expo projects today, and build apps that are production-ready and easy to maintain! ๐Ÿš€

ย