ナビゲーションとルーティングのアーキテクチャ
スタック、タブ、ディープリンク、ルートガードを使い、アプリの成長後も画面遷移を予測しやすい、整理された拡張可能なナビゲーション層を設計します。
「ナビゲーションとルーティングのアーキテクチャ」はCoddyKit上の無料Indie Hacker Mobile Appsレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはIndie Hacker Mobile Apps学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Indie Hacker Mobile Appsコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Navigation Is Architecture
How users move through your app is a core architectural concern, not an afterthought. A messy navigation layer leaks state and breaks the back button.
This lesson covers patterns that keep flows predictable.
The Navigation Stack
Mobile navigation is built on a stack: pushing a screen adds it on top, going back pops it off.
- Push: go deeper
- Pop: go back
- Replace: swap the top screen
The stack mirrors the user's mental history.
Tabs and Nested Stacks
Most apps combine a tab bar with a stack inside each tab. Each tab keeps its own history, so switching tabs does not lose your place.
This nesting is the backbone of modern mobile UX.
Defining Routes
Centralize your route names so they are not scattered as magic strings. A route map keeps navigation consistent and refactor-safe.
const Routes = {
Home: 'home',
Profile: 'profile',
Settings: 'settings'
};
console.log(Routes.Profile);Passing Parameters
Screens often need data, like which item to show. Pass typed parameters with navigation rather than relying on global state.
function navigateToDetail(id) {
const params = { itemId: id };
return { route: 'detail', params };
}
console.log(navigateToDetail(42));Deep Linking
A deep link opens a specific screen from outside the app — a URL like myapp://item/42. Deep links power notifications, sharing, and marketing campaigns.
Map URL patterns to routes in one place.
Route Guards
Some screens require auth or a completed onboarding step. A route guard checks a condition before allowing navigation and redirects if it fails.
function canEnter(route, isLoggedIn) {
const protectedRoutes = ['profile', 'settings'];
if (protectedRoutes.includes(route) && !isLoggedIn) return 'login';
return route;
}
console.log(canEnter('profile', false));Separating Navigation from Screens
Screens should not know how navigation works internally. Inject a navigation service or callback so screens stay testable and reusable.
This decoupling keeps your architecture clean.
Handling Back Behavior
The hardware back button on Android and gestures on iOS must behave sensibly. Decide per screen whether back exits a flow, confirms a discard, or is blocked.
Predictable back behavior is a hallmark of polish.
Avoiding Navigation Spaghetti
As apps grow, avoid these traps:
- Hardcoded route strings everywhere
- Deeply nested stacks no one understands
- Business logic inside navigation handlers
A central route map and guards keep complexity in check.
A Clean Navigation Layer
Put it together:
- Central route definitions
- Tabs wrapping nested stacks
- Typed parameters between screens
- Deep link mapping in one place
- Guards for protected routes
This structure scales from MVP to mature app.
Quick Check
Test your navigation architecture knowledge.
Recap
You designed a navigation layer:
- Stacks model push/pop history; tabs hold nested stacks
- Centralize route names and pass typed parameters
- Deep links open specific screens from outside
- Guards protect restricted routes
- Decouple navigation from screens for testability
Clean navigation keeps flows predictable as you scale.
よくある質問
「ナビゲーションとルーティングのアーキテクチャ」レッスンは無料ですか?
はい。「ナビゲーションとルーティングのアーキテクチャ」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Indie Hacker Mobile Appsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Indie Hacker Mobile Appsコースには全4レッスンが含まれています。
「ナビゲーションとルーティングのアーキテクチャ」で何を学びますか?
スタック、タブ、ディープリンク、ルートガードを使い、アプリの成長後も画面遷移を予測しやすい、整理された拡張可能なナビゲーション層を設計します。 ブラウザで直接実行するハンズオンコードでIndie Hacker Mobile Appsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Indie Hacker Mobile Appsを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのIndie Hacker Mobile Appsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「ナビゲーションとルーティングのアーキテクチャ」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このIndie Hacker Mobile Appsレッスンでコードを書いて実行できますか?
はい。すべてのIndie Hacker Mobile Appsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- モバイルアプリの状態管理
- ローカルデータの永続化
- RESTful APIの統合
- ナビゲーションとルーティングのアーキテクチャ