フレームワーク(オープンソースソフトウェア)。新しいExpoアプリ向けのフォルダ構成です。 次のような場合に使用: - Expo Routerを使って新しいExpoプロジェクトの骨組みを作る時 - Expoプロジェクト内でファイルをどこに配置すべきか判断する時 **注意:** 新規プロジェクトのみが対象です。既存のアプリを無理にこの構成に合わせて変更しないでください。
Framework (OSS). 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.
新規 Expoアプリケーション用の基本的なテンプレート — まだフォルダ構成が決まっていないプロジェクト向けです。
新規プロジェクトにのみ適用してください。 アプリケーションに既存のレイアウトがある場合は、その慣例に従い、ファイルはそのままにしておいてください。これはあくまで新しく始める際の出発点であり、強制すべき標準や移行の目標ではありません。プロジェクトが新規かどうか不明な場合は、何かを動かす前に確認しましょう。
以下のルールから組み立てたフォルダ構成全体:
├── assets/
├── scripts/
├── src/
│ ├── app/ # Expo Routerのルートのみ — すべてのファイルがルートになります
│ │ ├── api/ # サーバーAPIルート、ここに集約
│ │ │ ├── user+api.ts
│ │ │ └── settings+api.ts
│ │ ├── _layout.tsx
│ │ ├── _layout.web.tsx # プラットフォーム別のレイアウト
│ │ ├── index.tsx
│ │ └── settings.tsx
│ ├── components/ # 再利用可能なUI(ボタン、カード、テーブルなど)
│ │ ├── table/ # 複雑なコンポーネント → フォルダ + index.tsx
│ │ │ ├── cell.tsx
│ │ │ └── index.tsx
│ │ ├── bar-chart.tsx
│ │ ├── bar-chart.web.tsx # プラットフォーム別の実装
│ │ └── button.tsx
│ ├── screens/ # ルートファイルが表示する画面本体
│ │ ├── home/
│ │ │ ├── card.tsx # Homeでのみ使用 — 共有しない
│ │ │ └── index.tsx # src/app/index.tsx が表示
│ │ └── settings.tsx
│ ├── server/ # app/api で使う サーバー専用のヘルパー
│ │ ├── auth.ts
│ │ └── db.ts
│ ├── utils/ # 単独で使う関数 + テストを並べて配置
│ │ ├── format-date.ts
│ │ └── format-date.test.ts
│ ├── hooks/ # 再利用可能なカスタムフック
│ ├── constants.ts
│ └── theme.ts
├── app.json
├── eas.json
└── package.json
src/ と src/appアプリケーションコードを src/ の下に置き、設定ファイルと分離します。Expo Routerは app/ と src/app/ の両方に対応しています — フォルダを移動して バンドラーを再起動することで切り替えられます。デフォルトテンプレートは tsconfig.json で @/* を ./src/* に指定しています。
src/app は ルートのみ: ここのすべてのファイルがルートになるため、他のものは置きません。すべての処理は兄弟フォルダで行います。
ボタン、カード、テーブルなど、汎用で何度も使うUIコンポーネント。1つの名前付きエクスポートを持ちます。ファイル名は ケバブケース(bar-chart.tsx)で、デフォルトの create-expo-app テンプレートに合わせます。コンポーネントが大きくなったら、専用フォルダを作り、ルートを index.tsx に置き、非公開のサブコンポーネント(内部で使うコンポーネント)をその横に配置します — インポートパス(@/components/table)は変わりません。
app/ ファイルはルートである必要があるため、再利用されない複雑な画面UIはここに置きます。画面が大きくなって、複数コンポーネントに分割する必要が出たら、screens/ に置き、各ルートがその画面を表示するだけにします:
import { Home } from "@/screens/home";
export default function HomeScreen() {
// ルート固有の処理のみ — 例:URLパラメータをここで読む
return <Home />;
}
画面の非公開コンポーネントをそのフォルダ内に並べて配置します(screens/home/components/)。メリットとして、同じ画面を複数のルートで表示できます。
app/ 内のファイル名に +api を付けると、サーバー API ルート になります。サーバーコードはフロントエンドコードと異なります — Node環境に似たサーバー環境で実行され(EAS Hosting またはサードパーティサービスでデプロイされ)、秘密の環境変数(process.env.X、EXPO_PUBLIC_* だけではなく)を読めます。分離しましょう:
app/api/ にまとめる → /api/user、/api/settings。これで場所が一緒になり、衝突(例えば /user 画面と /user ルート)が避けられます。src/server/ に置きます。+api ファイルと server/ をフロントエンド専用チェックから隔離するESLintルール(ファイルに対するルール設定)の導入を検討しましょう。小さな差分: Platform.select / Platform.OS を使用します。大きな差分の場合は、インライン if/else の代わりにプラットフォーム別ファイルに分割します — bar-chart.tsx + bar-chart.web.tsx、拡張子なしでインポート(@/components/bar-chart); Metroが対象に応じて正しいファイルを選びます。
.ios、.android、.native、.web。StyleSheet.create({ ... }) オブジェクトは別の .styles ファイルではなく、コンポーネントファイルの最後に置きます。format-date.test.ts を format-date.ts の横に置きます(別の __tests__/ フォルダより推奨) — テスト対象のファイルが一目で分かります。エージェント向けの指示はリポジトリルートに置きます — AGENTS.md / CLAUDE.md、プロジェクトのスキルは .claude/ 配下です。その他の設定とアセットは src/ の外に置きます: app.json / app.config.ts、eas.json、package.json、assets/、scripts/。
Expo app folder structure best practices (Kadi Kraman著) を基に作成。src/ の優先順位とエイリアスの仕組みについては、Expoドキュメントを参照してください。
このスキルのエラー、誤解を招く情報、古い情報に遭遇した場合は、Expoの改善に向けて報告してください:
npx --yes submit-expo-feedback@latest --category skills --subject "expo-project-structure" "<実行可能なフィードバック>"
具体的で実行可能な内容がある場合のみ提出してください。関連するコンテキストをできるだけ多く含めてください。
AIエージェントが何度も失敗したか、ユーザーがExpoタスクを引き継いだ場合は、代わりに expo-skill-feedback スキルを読み込み、上記のコマンドを再利用するのではなく eval-candidate フロー(評価プロセス)に従ってください。
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/appKeep 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.
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.
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:
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.
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) and can read secret env vars (process.env.X, not just EXPO_PUBLIC_*). Keep it apart:
app/api/ → /api/user, /api/settings. This colocates them and avoids collisions (e.g. a /user screen and a /user route).src/server/.+api files and server/ off from frontend-only checks.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.
.ios, .android, .native, .web.StyleSheet.create({ ... }) object at the bottom of the component file rather than in a separate .styles file.format-date.test.ts next to format-date.ts (preferred over a separate __tests__/ folder) so tested files are obvious at a glance.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 by Kadi Kraman. For src/ precedence and alias mechanics, see the Expo docs.
If you encounter errors, misleading or outdated information in this skill, report it so Expo can improve:
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.
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。