Skip to main content

Command Palette

Search for a command to run...

Recommended Folder Structure React Native Expo

Published
β€’4 min read
Recommended Folder Structure React Native  Expo
project-root/
β”‚
β”œβ”€β”€ app/                          # If you're using Expo Router (v2+)
β”‚   β”œβ”€β”€ _layout.tsx               # Main layout (like stack navigation)
β”‚   β”œβ”€β”€ index.tsx                 # Home screen (default route)
β”‚   β”œβ”€β”€ auth/                     # Auth-related screens
β”‚   β”‚   β”œβ”€β”€ login.tsx
β”‚   β”‚   └── register.tsx
β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”œβ”€β”€ index.tsx
β”‚   β”‚   └── profile.tsx
β”‚   └── (other routes...)
β”‚
β”œβ”€β”€ src/                          # If you’re not using Expo Router
β”‚   β”œβ”€β”€ screens/                  # All main app screens
β”‚   β”‚   β”œβ”€β”€ HomeScreen.tsx
β”‚   β”‚   β”œβ”€β”€ LoginScreen.tsx
β”‚   β”‚   β”œβ”€β”€ ProfileScreen.tsx
β”‚   β”‚   └── index.ts              # Optional barrel export
β”‚   β”‚
β”‚   β”œβ”€β”€ components/               # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ Button.tsx
β”‚   β”‚   β”œβ”€β”€ InputField.tsx
β”‚   β”‚   β”œβ”€β”€ Header.tsx
β”‚   β”‚   └── index.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ modals/                   # All modal components
β”‚   β”‚   β”œβ”€β”€ CoinsPopup.tsx
β”‚   β”‚   β”œβ”€β”€ ConfirmDialog.tsx
β”‚   β”‚   └── index.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ hooks/                    # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ useAuth.ts
β”‚   β”‚   β”œβ”€β”€ useFetch.ts
β”‚   β”‚   └── useDebounce.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ context/                  # React Context providers
β”‚   β”‚   β”œβ”€β”€ AuthContext.tsx
β”‚   β”‚   β”œβ”€β”€ ThemeContext.tsx
β”‚   β”‚   └── index.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ utils/                    # Helper functions and constants
β”‚   β”‚   β”œβ”€β”€ date.ts
β”‚   β”‚   β”œβ”€β”€ number.ts
β”‚   β”‚   β”œβ”€β”€ storage.ts
β”‚   β”‚   └── index.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ types/                    # TypeScript interfaces & types
β”‚   β”‚   β”œβ”€β”€ navigation.ts
β”‚   β”‚   β”œβ”€β”€ user.ts
β”‚   β”‚   β”œβ”€β”€ api.ts
β”‚   β”‚   └── index.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ services/                 # API calls or external services
β”‚   β”‚   β”œβ”€β”€ apiClient.ts
β”‚   β”‚   β”œβ”€β”€ authService.ts
β”‚   β”‚   └── userService.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ config/                   # App-wide configuration
β”‚   β”‚   β”œβ”€β”€ env.ts
β”‚   β”‚   β”œβ”€β”€ constants.ts
β”‚   β”‚   └── theme.ts
β”‚   β”‚
β”‚   └── navigation/               # Navigation setup (if not using Expo Router)
β”‚       β”œβ”€β”€ AppNavigator.tsx
β”‚       └── AuthNavigator.tsx
β”‚
β”œβ”€β”€ assets/                       # Static assets (images, fonts, icons)
β”‚   β”œβ”€β”€ fonts/
β”‚   β”œβ”€β”€ icons/
β”‚   └── images/
β”‚
β”œβ”€β”€ .env                          # Environment variables
β”œβ”€β”€ app.json                      # Expo configuration
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── README.md

🧠 Why This Structure Works

FolderPurpose
screens/Each screen in your app (Login, Home, etc.)
components/Small reusable UI pieces (Button, InputField, etc.)
modals/Isolated modal components (CoinsPopup, AlertModal, etc.)
hooks/Custom hooks (API fetching, form handling, etc.)
context/Global app context (AuthContext, ThemeContext)
utils/Helper and formatting functions
types/TypeScript interfaces & enums
services/API handling or third-party integrations
config/Environment, theme, and app-wide constants
navigation/Stack, Tab, or Drawer navigators (if not using Expo Router)

🧠 Why Expo Uses These Characters

SymbolUsed ForWhy
_Layout or private routeKeeps layout files distinct from screens
()Route groupTo group related routes without affecting URL
[]Dynamic parameterTo define variable route parts
+Special routesSystem-level routes like +not-found or +error

πŸ“ Folder/File Conventions Explained

ExampleMeaning
_layout.tsx/app/_layout.tsxDefines a layout shared by all routes in the same folder (like a Stack, Tab, or Drawer). Every route inside that folder is wrapped with this layout.
index.tsx/app/index.tsxThe default route for that folder (like HomeScreen). When you navigate to /, this screen is shown.
[id].tsx/app/[id].tsxA dynamic route β€” used for screens that depend on a variable parameter. Example: /users/[id] β†’ /users/123 or /users/abc. You can access it via const { id } = useLocalSearchParams().
(group)/app/(auth)/login.tsxA route group β€” used to organize routes without affecting navigation paths. Useful for grouping related screens (like (auth), (tabs), (admin)), but the folder name doesn’t appear in the URL.
+not-found.tsx/app/+not-found.tsxShown automatically when a route isn’t found (like a 404 page).
_layout.tsx inside (group)/app/(tabs)/_layout.tsxDefines a Tab or Stack layout specific to that group of routes.
[...slug].tsx/app/docs/[...slug].tsxA catch-all route β€” matches multiple nested paths (e.g., /docs/getting-started/setup).
[[...slug]].tsx/app/docs/[[...slug]].tsxAn optional catch-all route β€” works with or without parameters.
_sitemap.ts/app/_sitemap.tsUsed to generate sitemap for web apps. Optional.

Example Structure (Tabs + Auth + Dynamic)

app/
β”‚
β”œβ”€β”€ _layout.tsx               # Root layout (global stack)
β”‚
β”œβ”€β”€ (auth)/                   # Auth group (won’t appear in URL)
β”‚   β”œβ”€β”€ _layout.tsx           # Stack layout for auth flow
β”‚   β”œβ”€β”€ login.tsx
β”‚   └── register.tsx
β”‚
β”œβ”€β”€ (tabs)/                   # Tabs group
β”‚   β”œβ”€β”€ _layout.tsx           # Tab navigation layout
β”‚   β”œβ”€β”€ home.tsx
β”‚   β”œβ”€β”€ profile/
β”‚   β”‚   β”œβ”€β”€ index.tsx         # Profile main screen
β”‚   β”‚   └── [id].tsx          # Dynamic user profile (e.g. /profile/123)
β”‚   └── settings.tsx
β”‚
└── +not-found.tsx            # 404 screen

πŸ” How this works:

  • / β†’ goes to (tabs)/home.tsx (main screen)

  • /profile β†’ opens (tabs)/profile/index.tsx

  • /profile/123 β†’ opens (tabs)/profile/[id].tsx

  • /login β†’ opens (auth)/login.tsx

(auth) and (tabs) help you organize your routes but don’t appear in URLs.