Coding & Developmentπuniversal
expo-project-structure
plugins/expo/skills/expo-project-structure/SKILL.md
Folder structure for a new Expo app. Use when scaffolding or laying out a new Expo project with Expo Router, or deciding where a file should live in one. For new projects only β never restructure an existing app to match.
Quick Start
Install this SKILL.md
npx skills add https://github.com/expo/skills/tree/main/plugins/expo/skills/expo-project-structure---
name: expo-project-structure
description: Folder structure for a new Expo app. Use when scaffolding or laying out a new Expo project with Expo Router, or deciding where a file should live in one. For new projects only β never restructure an existing app to match.
version: 1.0.0
license: MIT
---
# Expo Project Structure
A starting skeleton for a **new** Expo app β one with no committed folder structure yet.
**Apply only to new projects.** If the app already has a layout, follow its existing conventions and leave files where they are β a default to start from, never a standard to enforce or migrate toward. When unsure whether a project is new, ask before moving anything.
The whole layout, assembled from the rules below:
```
βββ assets/
βββ scripts/
βββ src/
β βββ app/ # Expo Router routes ONLY β every file is a route
β β βββ api/ # server API routes, grouped here
β β β βββ user+api.ts
β β β βββ settings+api.ts
β β βββ _layout.tsx
β β βββ _layout.web.tsx # platform-specific layout
β β βββ index.tsx
β β βββ settings.tsx
β βββ components/ # reusable UI: button, card, tableβ¦
β β βββ table/ # complex component β folder + index.tsx
β β β βββ cell.tsx
β β β βββ index.tsx
β β βββ bar-chart.tsx
β β βββ bar-chart.web.tsx # platform-specific variant
β β βββ button.tsx
β βββ screens/ # screen bodies that route files render
β β βββ home/
β β β βββ card.tsx # used only by Home β not shared
β β β βββ index.tsx # rendered by src/app/index.tsx
β β βββ settings.tsx
β βββ server/ # server-only helpers used by app/api
β β βββ auth.ts
β β βββ db.ts
β βββ utils/ # standalone helpers + colocated tests
β β βββ format-date.ts
β β βββ format-date.test.ts
β βββ hooks/ # reusable hooks: use-theme.tsβ¦
β βββ constants.ts
β βββ theme.ts
βββ app.json
βββ eas.json
βββ package.json
```
## `src/` and `src/app`
Keep app code under `src/` to separate it from config files. Expo Router supports both `app/` and `src/app/` out of the box β to switch, move the folder and restart the bundler. The default template aliases `@/*` to `./src/*` in `tsconfig.json`.
`src/app` is **routes-only**: every file there becomes a route, so nothing else belongs in it. Everything below lives in sibling folders.
## components/ β reusable UI
Generic, reused UI (button, card, table) with one named export each. Name files in **kebab-case** (`bar-chart.tsx`), matching the default `create-expo-app` template. When a component grows, give it its own folder with the root in `index.tsx` and **colocate** its private sub-components beside it β the import path (`@/components/table`) stays unchanged.
## screens/ β screen bodies
Because `app/` files must be routes, complex screen UI that isn't reused has no home there. Once a screen grows big enough to need breaking out to separate components, put it in `screens/` and let each route just render its screen:
```tsx
import { Home } from "@/screens/home";
export default function HomeScreen() {
// route-specific concerns only β e.g. read url params here
return <Home />;
}
```
**Colocate** a screen's private components inside its folder (`screens/home/components/`). A bonus: the same screen can render under multiple routes.
## server/ + app/api/ β separate server code
Appending `+api` to a file in `app/` makes it a server **API route**. Server code is different from frontend code β it runs in a Node-like server environment (deployed with EAS Hosting or on [third-party services](https://docs.expo.dev/router/web/api-routes/#hosting-on-third-party-services)) and can read secret env vars (`process.env.X`, not just `EXPO_PUBLIC_*`). Keep it apart:
- Group all routes under `app/api/` β `/api/user`, `/api/settings`. This colocates them and avoids collisions (e.g. a `/user` screen and a `/user` route).
- Put shared server-only helpers in `src/server/`.
- Consider ESLint rules that fence `+api` files and `server/` off from frontend-only checks.
## Platform-specific code
Small differences: use `Platform.select` / `Platform.OS`. For larger ones, split into platform files instead of inline `if/else` β `bar-chart.tsx` + `bar-chart.web.tsx`, imported extension-free (`@/components/bar-chart`); Metro picks the right file per target.
- Props must be identical across variants.
- A default file (no platform extension) is always required β make it a no-op if the component is single-platform.
- Supported extensions: `.ios`, `.android`, `.native`, `.web`.
## Colocate styles and tests
- **Styles:** keep the `StyleSheet.create({ ... })` object at the bottom of the component file rather than in a separate `.styles` file.
- **Tests:** put `format-date.test.ts` next to `format-date.ts` (preferred over a separate `__tests__/` folder) so tested files are obvious at a glance.
## AI and config files
Agent instructions live at the repo root β `AGENTS.md` / `CLAUDE.md`, with project skills under `.claude/`. Other config and assets stay outside `src/`: `app.json` / `app.config.ts`, `eas.json`, `package.json`, `assets/`, and `scripts/`.
---
Based on [Expo app folder structure best practices](https://expo.dev/blog/expo-app-folder-structure-best-practices) by Kadi Kraman. For `src/` precedence and alias mechanics, see the [Expo docs](https://docs.expo.dev/router/reference/src-directory/).
## Submitting Feedback
If you encounter errors, misleading or outdated information in this skill, report it so Expo can improve:
```bash
npx --yes submit-expo-feedback@latest --category skills --subject "expo-project-structure" "<actionable feedback>"
```
Only submit when you have something specific and actionable to report. Include as much relevant context as possible.
If an AI agent repeatedly failed or the user had to take over an Expo task, load the expo-skill-feedback skill and follow its eval-candidate flow instead of reusing the command above.
Related Skills
More coding & development skills you might like
Reticle
Coding & DevelopmentAI agents can generate code, but still struggle to understand what they build. Reticle brings Jev-style machine-native runtime perception to web & desktop applications.
π€claudeπuniversal
1.2k
190
View
agentscope-java
Coding & DevelopmentExpert Java developer skill for AgentScope Java framework - a reactive, message-driven multi-agent system built on Project Reactor. Use when working with reactive programming, LLM integration, agent orchestration, multi-agent systems, or when the user mentions AgentScope, ReActAgent, Mono/Flux, Project Reactor, or Java agent development. Specializes in non-blocking code, tool integration, hooks, pipelines, and production-ready agent applications.
πuniversal
6.0k
1.5k
View
ospec
Coding & DevelopmentDocument-driven OSpec workflow for initialization, change/goal routing, validation, archiving, and durable project knowledge.
β¨geminiπ€claudeπ¬gptπuniversal
524
34
View
misakanet-failure-memory
Coding & Developmentπ A zero-dependency, git-backed micro-lesson library for AI Agents to asynchronously share and search verified debugging experience. Python stdlib only. | https://misakanet.org
π€claudeβ¨οΈcursorπuniversal
424
158
View