BookNest Navigation

Wiring Up BookNest's Navigation

BookNest now starts from expo-router/entry instead of index.ts and App.tsx. The screens from earlier sections moved into routes, and everything that is not a screen stayed in src/:

BookNest's routesJSX
find src/app -type f | sort
Output
src/app/(tabs)/_layout.tsx
src/app/(tabs)/cart.tsx
src/app/(tabs)/index.tsx
src/app/+native-intent.tsx
src/app/+not-found.tsx
src/app/_layout.tsx
src/app/book/[id].tsx
src/app/checkout.tsx
src/app/demo.tsx
src/app/notes/[id].tsx
src/app/sign-in.tsx

demo.tsx is a development aid: booknest:///demo opens whichever section demo src/demos/Current.tsx points at, so the smaller examples in this chapter still run inside the same app. The cart and the signed-in user live in src/session.tsx, a React 7,897 context with cart, add(), remove(), user and setUser(), which the root layout provides.

The flow matches Planning BookNest's plan, and every screen has a URL, so booknest://book/3, https://booknest.example.com/book/3 and the old booknest://item?id=3 links all land on the same screen.

Two weaknesses remain. Every context change re-renders every screen that calls useSession(); Query and Zustand moves the cart into a Zustand 58,763 store that screens subscribe to selectively. And the catalog still reads a local JSON file; Fetching the Catalog fetches it with TanStack Query 79,069 . Run npx tsc --noEmit before you move on: with typed routes on, it checks every link in the app.