Indie Hacker Mobile Apps · Lekcja

Architektura nawigacji i routingu

Zaprojektują Państwo przejrzystą i skalowalną warstwę nawigacji aplikacji mobilnej, wykorzystując stosy, karty, deep linki i strażników tras, które zapewniają przewidywalność przepływów wraz z rozwojem aplikacji.

Lekcja 4 z 413 kroki

Architektura nawigacji i routingu to bezpłatna lekcja Indie Hacker Mobile Apps na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Indie Hacker Mobile Apps, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Indie Hacker Mobile Apps zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

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.

Bezpłatny start

Ucz się Indie Hacker Mobile Apps dzięki korepetycjom AI — za darmo

Pisz i uruchamiaj kod w przeglądarce, otrzymuj natychmiastową pomoc od korepetytora AI dostępnego 24/7 i kontynuuj naukę w sieci lub w aplikacji.

Kursy
12
Lekcje
48

Często zadawane pytania

Czy lekcja „Architektura nawigacji i routingu” jest bezpłatna?

Tak — pełny tekst „Architektura nawigacji i routingu” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Indie Hacker Mobile Apps, przejdź na CoddyKit PRO. Kurs Indie Hacker Mobile Apps zawiera 4 lekcji w sumie.

Co nauczysz się w „Architektura nawigacji i routingu”?

Zaprojektują Państwo przejrzystą i skalowalną warstwę nawigacji aplikacji mobilnej, wykorzystując stosy, karty, deep linki i strażników tras, które zapewniają przewidywalność przepływów wraz z rozwoj… Ćwiczysz Indie Hacker Mobile Apps z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Indie Hacker Mobile Apps?

Nie wymagamy żadnego doświadczenia. Indie Hacker Mobile Apps w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Architektura nawigacji i routingu”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Indie Hacker Mobile Apps?

Tak. Każda lekcja Indie Hacker Mobile Apps zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Zarządzanie stanem w aplikacjach mobilnych
  2. Trwałe przechowywanie danych lokalnych
  3. Integracja interfejsów RESTful API
  4. Architektura nawigacji i routingu
← Powrót do Indie Hacker Mobile Apps