SyntaxPilot
Courses/Vibe Coding/Lesson 23
Video coming soonThis lesson’s video is being made

Start with the notes below; the video appears here as soon as it is on YouTube.

Vibe Coding · Lesson 23 of 40

Mobile apps with AI

React Native/Expo or Flutter in plain wordsrunning on your phonescreens and navigationdevice permissionslimits of AI for native code

Vibe Coding: build real apps with AI · Episode 23. Every agent run below is real: Claude Code 2.1.322 (model claude-opus-5-5) in print mode (claude -p --permission-mode acceptEdits), on 12 November 2026, in /home/asha/projects/park-buddy (a Git repository). The agent could not run commands or read web pages without approval, so it could not install, run or test anything; we did, and every output and screenshot below is from a real run.

The project: made with npx create-expo-app@latest: Expo SDK 58.0.24, React Native 0.88.1, react-native-web 0.21.4, Expo Router 58.0.31; the AI's app added expo-location 58.0.21 and expo-sqlite 58.0.16.

About the phone: this video was made on a cloud computer with no phone attached. We ran the app with npx expo start and looked at its web version in a phone-sized Chromium window (Playwright emulating a Pixel 7, 412×915, with a made-up location and India time). "Don't allow" was simulated by not granting the browser the location permission. On your own computer, you run the same project on your phone (see "Running it on your phone" below).

The problem: where did I park?

Papa rides his scooter to the mall and parks in the basement: three levels, hundreds of scooters, every pillar looks the same. Two hours later: B2 or B3? Twenty minutes of walking, every time. Asha's idea: an app with one big button, I parked here, that saves the place, the time and a note like "B2, pillar 14". But Papa has an Android phone and Mummy has an iPhone.

The obvious way: build it twice

Android and iPhone build their screens from different parts. From the React Native docs ("Core Components and Native Components"):

React Native component Android view iOS view Web analog What it is
<View> <ViewGroup> <UIView> a non-scrolling <div> a box that holds other things
<Text> <TextView> <UITextView> <p> text
<Image> <ImageView> <UIImageView> <img> a picture
<TextInput> <EditText> <UITextField> <input type="text"> a box to type in

Two separate apps means two sets of building blocks, two copies of every feature and two of every bug. And building for iPhone needs a Mac: create-expo-app itself prints "npm run ios # you need to use macOS to build the iOS project - use the Expo app if you need to do iOS development without a Mac".

React Native and Expo (one film, dubbed for every audience)

A film A phone app
One script, shot once React Native: you write the app once, in JavaScript, as components
Dubbed into Hindi, Tamil...: each audience hears its own language Native views: "At runtime, React Native creates the corresponding Android and iOS views" (React Native docs)
The studio that handles cameras, dubbing and release Expo: the tools around React Native to create, run and build the app
  • A component is a building block of the screen (<View>, <Text>, a button you make yourself).
  • A native app is one built from the phone's own parts, installed like any other app, as opposed to a web page in the browser.
  • Flutter is the other big option. Its FAQ: "Flutter is Google's open source framework for crafting beautiful, natively compiled applications for mobile (iOS, Android), web, desktop (macOS, Windows, Linux), and embedded devices from a single codebase." It uses the language Dart. Same idea, different tools; we use Expo because it's JavaScript, which this course already uses.

Creating the project (real)

$ npx create-expo-app@latest park-buddy
✔ Downloaded and extracted project files.
✅ Your project is ready!
- npm run android
- npm run ios # you need to use macOS to build the iOS project - use the Expo app
  if you need to do iOS development without a Mac
- npm run web

$ head -5 park-buddy/AGENTS.md
This is an Expo/React Native mobile application. ...
## Expo has changed — do not trust your training data
Expo ships breaking changes every SDK release. APIs you remember are likely
renamed, moved, or removed.

An SDK (software development kit) is the toolbox of one version; this project is Expo SDK 58. The template ships an AGENTS.md, a file of instructions for AI coding agents, and it says plainly: don't trust your training data, read the docs for this SDK. Keep that in mind.

Running it on your phone

$ npx expo start
Using src/app as the root directory for Expo Router.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█ ▄▄▄▄▄ █ ██▀▀ ▀▄██ ▄▄▄▄▄ █
  ... (QR code)
› Scan the QR code above to open in Expo Go.
› Metro: exp://192.0.2.2:8081
› Web: http://localhost:8081
› Press a │ open Android
› Press w │ open web
  • Metro is the bundler: it packs all your code into one bundle the phone (or browser) loads.
  • Expo Go is Expo's free app: install it on your phone, scan the QR code, and your project opens on the phone, as long as the phone can reach your computer (usually the same Wi-Fi).
  • Two notes from Expo's docs (12 Nov 2026): Expo Go is "a playground for students and learners", "not useful for building production-grade projects"; for real apps use a development build (a build of your own app with Expo's developer tools, which "Support custom native modules"). And during the SDK 58 transition, the "Create a project" page says: "If you plan to use Expo Go on a physical device, use an SDK 57 project."
  • Pressing w opens the web version in a browser. That's what this video shows, because no phone is attached to our cloud computer.

Why web habits break (real)

Asha's first try, the way she'd write a web page:

import { View } from "react-native";

export default function Index() {
  return (
    <View>
      I parked at B2, pillar 14
    </View>
  );
}

Real result (terminal and web preview):

Web  ERROR  Unexpected text node: I parked at B2, pillar 14. A text node cannot be a child of a <View>.

In the browser the text still appeared, which makes the bug easy to miss. Why: a phone has no HTML. Each component becomes a real phone part, and a box (View) can't hold loose text; text needs its own <Text> component. The project's own starter screen shows the right way:

import { Text, View, StyleSheet } from "react-native";

export default function Index() {
  return (
    <View style={styles.container}>
      <Text>Edit src/app/index.tsx to edit this screen.</Text>
    </View>
  );
}

Screens and navigation (a stack of plates)

A screen is one whole-display view of the app (home, one spot's details). Navigation is moving between screens. Most phone apps use a navigation stack, like a stack of plates: opening a screen puts it on top (push), Back takes the top one off (pop).

// Screens on a phone work like a stack of plates
const stack = [];
function open(screen) {
  stack.push(screen);
  console.log("open", screen.padEnd(16), "| stack:", stack.join("  >  "));
}
function back() {
  const top = stack.pop();
  console.log("back", top.padEnd(16), "| stack:", stack.join("  >  "));
}

open("/");                 // Home: the big button and past spots
open("/spot/1794478");     // tap a spot: Details goes ON TOP
back();                    // Back: take the top one off

Real output (Node.js):

open /                | stack: /
open /spot/1794478    | stack: /  >  /spot/1794478
back /spot/1794478    | stack: /

Expo Router: every file is a screen

From Expo's docs: "Expo Router is a file-based router for React Native and web applications." "When a file is added to the app directory, the file automatically becomes a route in your navigation." A route is a screen's address, like / or /spot/123. The AI's app:

src/app/_layout.tsx        →  the Stack: how screens are arranged
src/app/index.tsx          →  screen "/"            (Home)
src/app/spot/[id].tsx      →  screen "/spot/123..."  (one spot's details)
src/lib/location.ts        →  not a screen: helper code
src/lib/spots.ts           →  not a screen: saving spots on the phone

[id] in square brackets is a dynamic route: a fill-in-the-blank part, so one file serves every spot. _layout.tsx says how screens are arranged (here a Stack).

Prompt 1: the AI builds Park Buddy

claude -p "Papa always forgets where he parked his scooter in the mall basement. Build a small phone app in this Expo project, for Android and iPhone: a home screen with a big \"I parked here\" button that saves where he is (his location, the time, and an optional note like \"B2, pillar 14\"), a list of his past spots, and tapping a spot opens a second screen with the details and a button to open that place in a maps app. Keep the spots saved on the phone so they are still there after he closes the app. Keep it simple." --permission-mode acceptEdits

What really happened (log shortened): it tried to read Expo's docs index (docs.expo.dev/llms.txt), as AGENTS.md asks, which needed approval; tried npx expo install expo-location expo-sqlite, approval again; then wrote src/lib/spots.ts, src/lib/location.ts, src/lib/theme.ts, src/app/_layout.tsx, src/app/index.tsx, src/app/spot/[id].tsx and the location permission text in app.json. Its reply: "I've written the app, but it won't run yet. The two packages it needs ... aren't installed ... none of this has been checked or run. I also couldn't look up the SDK 58 docs ... so the Expo API calls are written from memory." It also warned that GPS is weak in basements: "Even with a location, it will probably only point to the mall, not the exact spot, so the note is what will find the scooter."

First run: a missing package (real)

$ npx expo start
Metro error: Failed to resolve plugin for module "expo-sqlite" relative to
  "/home/asha/projects/park-buddy". Do you have node modules installed?

$ EXPO_OFFLINE=1 npx expo install expo-location expo-sqlite
› Installing 2 SDK 58.0.0 compatible native modules using npm
added 5 packages
$ npx tsc --noEmit
$                          (no errors)

The AI had listed expo-sqlite in app.json but nobody had installed it. npx expo install picks versions that match your SDK (we used offline mode only because our cloud computer can't reach Expo's version server). npx tsc --noEmit is the typecheck: TypeScript checks the types without running anything.

Next: the web can't load SQLite (real)

Unable to resolve module ./wa-sqlite/wa-sqlite.wasm from node_modules/expo-sqlite/web/worker.ts
> 23 | import wasmModule from './wa-sqlite/wa-sqlite.wasm';

expo-sqlite keeps data in a small SQLite database (a database stored in one file). On a phone it uses the phone's own; in a browser it loads a WebAssembly (.wasm) file. Expo's SQLite docs: "To use expo-sqlite on web, you need to configure Metro bundler to support wasm files", and you "need to add the Cross-Origin-Embedder-Policy and Cross-Origin-Opener-Policy headers". The app uses expo-sqlite/kv-store, which the docs describe as "a drop-in replacement for the @react-native-async-storage/async-storage library": a key-value store, like a labelled locker (key "spots" → the saved list as text).

Prompt 2: the exact error

claude -p "I installed the two packages (expo-location, expo-sqlite) and the typecheck passes. I'm testing in the web browser first (npx expo start, then w), because Papa has his phone with him today. The page shows a red \"Resolution Error\": Unable to resolve module ./wa-sqlite/wa-sqlite.wasm from node_modules/expo-sqlite/web/worker.ts (line 23: import wasmModule from './wa-sqlite/wa-sqlite.wasm'). Fix it so the app also runs in the browser. Change nothing else." --permission-mode acceptEdits

It added one file, metro.config.js (full file below), and said it copied the setup "from the setup notes that come with the installed expo-sqlite 58 package", then: "Metro only reads its config at startup. Run npx expo start --clear". After the restart the app worked: the home screen; tap with the note "B2, pillar 14"; the details screen at /spot/1794478327016-mnnihq with the note, the time and "28.56770, 77.32110 (within about 12 m)"; Back to / with the spot in the list; and after reloading the page, still saved.

Device permissions (a guest asks before opening your cupboard)

A phone guards private things (location, camera, microphone, contacts, photos). An app must ask the user first: that is a device permission.

  • Ask in context. Android's guide ("Request runtime permissions"): "Ask for a permission in context, when the user starts to interact with the feature that requires it."
  • Say why. On iPhone the question shows your usage description text (for location in use: NSLocationWhenInUseUsageDescription). In Expo you set it in app.json; Expo's permissions guide notes "Changes to the Info.plist cannot be updated over-the-air": changing it needs a new build of the app.
  • Respect "no". Android's guide: "gracefully degrade your app so that the user can continue using your app", and don't pressure them to change their mind.
  • Web: Expo's guide: "On the web, permissions like the Camera and Location can only be requested from a secure context" (https://, or http://localhost while developing).

The AI did the first two right:

export async function getCurrentCoords(): Promise<Coords | null> {
  const { status } = await Location.requestForegroundPermissionsAsync();
  if (status !== "granted") throw new PermissionDeniedError();
  ...
}

// app.json
["expo-location", {
  "locationWhenInUsePermission":
    "Park Buddy uses your location to remember where you parked."
}]

requestForegroundPermissionsAsync "Asks the user to grant permissions for location while the app is in the foreground" (Expo Location docs), and it runs only when Papa taps the button. Foreground means while the app is open on screen.

AI mistake: "Don't allow" lost the note (real)

We blocked location, typed "B2, pillar 14" and tapped I parked here: the spinner stopped, no message appeared, and "Past spots" still said "No spots yet". The note was gone. Why, in the AI's first version:

    } catch (e) {
      if (e instanceof PermissionDeniedError) {
        Alert.alert(
          "Location is off",
          "Park Buddy needs location permission to remember where you parked.",
          [
            { text: "Cancel", style: "cancel" },
            { text: "Open Settings", onPress: () => Linking.openSettings() },
          ],
        );
      }

and the installed react-native-web 0.21.4's Alert (node_modules/react-native-web/dist/exports/Alert/index.js):

class Alert {
  static alert() {}
}
  1. The spot was saved only inside the try part, after the location; a refusal skipped the saving entirely, on every platform.
  2. The message was an Alert (a pop-up dialog). On a phone it shows; on the web it is an empty function, so nothing appears.
  3. It pushed Papa to the Settings app, which Android's guide advises against.

The same logic in plain JavaScript (run with Node.js):

class PermissionDeniedError extends Error {}
class Alert { static alert() {} }   // react-native-web 0.21.4: exactly this, an empty function

const saved = [];   // stands in for the phone's storage
async function getCurrentCoords() {
  throw new PermissionDeniedError();   // Papa tapped "Don't allow"
}

// Version 1: the AI's first code (shortened)
async function parkV1(note) {
  try {
    const coords = await getCurrentCoords();
    saved.push({ note, coords });
  } catch (e) {
    Alert.alert("Location is off", "Park Buddy needs location permission...");
  }
}

// Version 3: after prompt 3 (shortened)
async function parkV3(note) {
  let coords = null, noLocation;
  try {
    coords = await getCurrentCoords();
  } catch (e) {
    noLocation = e instanceof PermissionDeniedError ? "denied" : "unavailable";
  }
  saved.push({ note, coords, noLocation });
}

(async () => {
  await parkV1("B2, pillar 14");
  console.log("After version 1:", JSON.stringify(saved));
  await parkV3("B2, pillar 14");
  console.log("After version 3:", JSON.stringify(saved));
})();

Real output:

After version 1: []
After version 3: [{"note":"B2, pillar 14","coords":null,"noLocation":"denied"}]

Prompt 3: save the note anyway

claude -p "It runs in the browser now, and saving with location works. Then I tested what happens when Papa taps \"Don't allow\" on the location question (I blocked location permission). Two problems:
1) In the browser nothing happens at all: the spinner stops and there is no message. react-native-web's Alert.alert is empty (node_modules/react-native-web/dist/exports/Alert/index.js is literally \`static alert() {}\`).
2) Worse, his note \"B2, pillar 14\" is not saved at all. You said yourself that in a basement the note is what will find the scooter.
Fix it: if location is refused or not available, still save the note and the time, and show the message on the screen itself (not a pop-up), so it works the same on Android, iPhone and the web. Don't keep pushing him to the Settings app. Change nothing else." --permission-mode acceptEdits

It changed three files (61 insertions, 27 deletions): the note and time are saved even without location, pop-ups became on-screen messages, the "Open Settings" button is gone. Retest with location still blocked: the details screen shows "Saved without location — Location is turned off for Park Buddy, so the place on the map was not saved. Your note and the time were saved.", the note "B2, pillar 14", "Location: Not available", and a greyed-out "Open in Maps". It also reported a problem it left alone because we said "change nothing else": "Delete spot" uses a pop-up too, so "In the browser that pop-up never appears, so delete does nothing there." We checked: true. That's your homework.

The limits of AI for phone code

  1. It can't hold the phone. It never saw a permission pop-up or tapped "Don't allow"; the biggest bug survived until we tested.
  2. Phone tools change every SDK. Even with the template's warning, without the docs it wrote "from memory".
  3. Phone ≠ web. Alert, SQLite and Settings behave differently in the browser.
  4. Native settings need a new build. Permission texts live in the app's native build (Info.plist on iPhone), not in the JavaScript you reload.
  5. The real world. A basement has weak GPS; no code fixes that (the AI said so itself).
  6. So you are the tester: test every path on a real phone: allow, don't allow, no signal.
$ git log --oneline
f9b0c79 Save the note even without location; on-screen messages (Claude Code, prompt 3)
8d6be74 Run on the web too: metro.config.js for expo-sqlite (Claude Code, prompt 2)
e3dcb0f Park Buddy v1 (Claude Code, prompt 1) + packages installed
35d543c Blank app (npm run reset-project)
b1cceca New Expo app (create-expo-app, SDK 58)

The finished app (the AI's real code, after prompts 1-3)

src/app/_layout.tsx

import { Stack } from "expo-router";
import { StatusBar } from "expo-status-bar";

import { useTheme } from "@/lib/theme";

export default function RootLayout() {
  const theme = useTheme();
  return (
    <>
      <StatusBar style="auto" />
      <Stack
        screenOptions={{
          headerStyle: { backgroundColor: theme.background },
          headerTintColor: theme.text,
          headerShadowVisible: false,
          contentStyle: { backgroundColor: theme.background },
        }}
      >
        <Stack.Screen name="index" options={{ title: "Park Buddy" }} />
        <Stack.Screen name="spot/[id]" options={{ title: "Parking spot" }} />
      </Stack>
    </>
  );
}

src/app/index.tsx

import { router, useFocusEffect } from "expo-router";
import { useCallback, useState } from "react";
import {
  ActivityIndicator,
  FlatList,
  Pressable,
  StyleSheet,
  Text,
  TextInput,
  View,
} from "react-native";

import { type Coords, getCurrentCoords, PermissionDeniedError } from "@/lib/location";
import { addSpot, formatTime, loadSpots, type Spot } from "@/lib/spots";
import { useTheme } from "@/lib/theme";

export default function Home() {
  const theme = useTheme();
  const [spots, setSpots] = useState<Spot[]>([]);
  const [note, setNote] = useState("");
  const [saving, setSaving] = useState(false);
  const [error, setError] = useState<string | null>(null);

  // Reload whenever we come back to this screen (e.g. after deleting a spot)
  useFocusEffect(
    useCallback(() => {
      loadSpots().then(setSpots);
    }, []),
  );

  async function handleParkHere() {
    setSaving(true);
    setError(null);
    try {
      // Location is a bonus: if it's refused or not found, still save the
      // note and the time. In a basement the note is what finds the scooter.
      let coords: Coords | null = null;
      let noLocation: "denied" | "unavailable" | undefined;
      try {
        coords = await getCurrentCoords();
        if (!coords) noLocation = "unavailable";
      } catch (e) {
        noLocation = e instanceof PermissionDeniedError ? "denied" : "unavailable";
      }
      const spot = await addSpot({
        latitude: coords?.latitude ?? null,
        longitude: coords?.longitude ?? null,
        accuracy: coords?.accuracy ?? null,
        savedAt: Date.now(),
        note: note.trim(),
      });
      setNote("");
      setSpots(await loadSpots());
      router.push({
        pathname: "/spot/[id]",
        params: noLocation ? { id: spot.id, noLocation } : { id: spot.id },
      });
    } catch {
      // Saving itself failed. The note stays in the box so nothing is lost.
      setError("Couldn't save. Please tap the button again.");
    } finally {
      setSaving(false);
    }
  }

  const header = (
    <View style={styles.header}>
      <TextInput
        value={note}
        onChangeText={setNote}
        placeholder='Note (optional), e.g. "B2, pillar 14"'
        placeholderTextColor={theme.muted}
        style={[
          styles.input,
          { backgroundColor: theme.card, color: theme.text, borderColor: theme.border },
        ]}
        returnKeyType="done"
      />
      <Pressable
        onPress={handleParkHere}
        disabled={saving}
        accessibilityRole="button"
        accessibilityLabel="I parked here"
        style={({ pressed }) => [
          styles.bigButton,
          { backgroundColor: theme.primary, opacity: pressed || saving ? 0.7 : 1 },
        ]}
      >
        {saving ? (
          <>
            <ActivityIndicator color={theme.onPrimary} size="large" />
            <Text style={[styles.bigButtonSub, { color: theme.onPrimary }]}>
              Finding your location…
            </Text>
          </>
        ) : (
          <Text style={[styles.bigButtonText, { color: theme.onPrimary }]}>
            I parked here
          </Text>
        )}
      </Pressable>
      {error ? (
        <Text
          accessibilityRole="alert"
          accessibilityLiveRegion="polite"
          style={[styles.error, { color: theme.danger }]}
        >
          {error}
        </Text>
      ) : null}
      <Text style={[styles.sectionTitle, { color: theme.muted }]}>Past spots</Text>
    </View>
  );

  return (
    <FlatList
      data={spots}
      keyExtractor={(s) => s.id}
      ListHeaderComponent={header}
      contentInsetAdjustmentBehavior="automatic"
      keyboardShouldPersistTaps="handled"
      contentContainerStyle={styles.list}
      ListEmptyComponent={
        <Text style={[styles.empty, { color: theme.muted }]}>
          No spots yet. Tap the big button when you park.
        </Text>
      }
      renderItem={({ item, index }) => (
        <Pressable
          onPress={() => router.push({ pathname: "/spot/[id]", params: { id: item.id } })}
          style={({ pressed }) => [
            styles.row,
            { backgroundColor: theme.card, borderColor: theme.border, opacity: pressed ? 0.6 : 1 },
          ]}
        >
          <View style={{ flex: 1 }}>
            <Text style={[styles.rowTitle, { color: theme.text }]} numberOfLines={1}>
              {item.note || "No note"}
            </Text>
            <Text style={[styles.rowSub, { color: theme.muted }]}>
              {formatTime(item.savedAt)}
              {index === 0 ? "  ·  Latest" : ""}
            </Text>
          </View>
          <Text style={[styles.chevron, { color: theme.muted }]}>›</Text>
        </Pressable>
      )}
    />
  );
}

const styles = StyleSheet.create({
  list: { padding: 16, gap: 10 },
  header: { gap: 16, marginBottom: 4 },
  input: {
    fontSize: 18,
    borderWidth: 1,
    borderRadius: 12,
    paddingHorizontal: 14,
    paddingVertical: 14,
  },
  bigButton: {
    minHeight: 160,
    borderRadius: 24,
    alignItems: "center",
    justifyContent: "center",
    gap: 8,
  },
  bigButtonText: { fontSize: 32, fontWeight: "700" },
  bigButtonSub: { fontSize: 16 },
  error: { fontSize: 17, fontWeight: "600", textAlign: "center" },
  sectionTitle: {
    fontSize: 15,
    fontWeight: "600",
    textTransform: "uppercase",
    marginTop: 8,
  },
  empty: { fontSize: 17, textAlign: "center", marginTop: 24 },
  row: {
    flexDirection: "row",
    alignItems: "center",
    borderWidth: 1,
    borderRadius: 14,
    padding: 16,
  },
  rowTitle: { fontSize: 19, fontWeight: "600" },
  rowSub: { fontSize: 15, marginTop: 4 },
  chevron: { fontSize: 28, marginLeft: 8 },
});

src/app/spot/[id].tsx

import { router, useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { Alert, Pressable, ScrollView, StyleSheet, Text, View } from "react-native";

import { openInMaps } from "@/lib/location";
import { deleteSpot, formatTime, getSpot, type Spot } from "@/lib/spots";
import { useTheme } from "@/lib/theme";

export default function SpotDetails() {
  const theme = useTheme();
  const { id, noLocation } = useLocalSearchParams<{
    id: string;
    /** set by the home screen right after saving a spot without location */
    noLocation?: "denied" | "unavailable";
  }>();
  const [spot, setSpot] = useState<Spot | null | undefined>(undefined);

  useEffect(() => {
    getSpot(id).then((s) => setSpot(s ?? null));
  }, [id]);

  if (spot === undefined) return null;

  if (spot === null) {
    return (
      <View style={styles.center}>
        <Text style={[styles.value, { color: theme.text }]}>This spot was deleted.</Text>
      </View>
    );
  }

  const hasLocation = spot.latitude != null && spot.longitude != null;

  function confirmDelete() {
    Alert.alert("Delete this spot?", undefined, [
      { text: "Cancel", style: "cancel" },
      {
        text: "Delete",
        style: "destructive",
        onPress: async () => {
          await deleteSpot(spot!.id);
          router.back();
        },
      },
    ]);
  }

  return (
    <ScrollView
      contentInsetAdjustmentBehavior="automatic"
      contentContainerStyle={styles.container}
    >
      {noLocation ? (
        <View
          accessibilityRole="alert"
          accessibilityLiveRegion="polite"
          style={[styles.notice, { backgroundColor: theme.card, borderColor: theme.primary }]}
        >
          <Text style={[styles.noticeTitle, { color: theme.text }]}>
            Saved without location
          </Text>
          <Text style={[styles.value, { color: theme.text }]}>
            {noLocation === "denied"
              ? "Location is turned off for Park Buddy, so the place on the map was not saved. Your note and the time were saved."
              : "The phone couldn't find your location here. Your note and the time were saved."}
          </Text>
        </View>
      ) : null}
      <View style={[styles.card, { backgroundColor: theme.card, borderColor: theme.border }]}>
        <Field label="Note" value={spot.note || "No note"} theme={theme} big />
        <Field label="Parked at" value={formatTime(spot.savedAt)} theme={theme} />
        <Field
          label="Location"
          value={
            hasLocation
              ? `${spot.latitude!.toFixed(5)}, ${spot.longitude!.toFixed(5)}` +
                (spot.accuracy != null ? `\n(within about ${Math.round(spot.accuracy)} m)` : "")
              : "Not available"
          }
          theme={theme}
        />
      </View>

      <Pressable
        disabled={!hasLocation}
        onPress={() => openInMaps(spot.latitude!, spot.longitude!, spot.note || "My scooter")}
        accessibilityRole="button"
        style={({ pressed }) => [
          styles.button,
          {
            backgroundColor: theme.primary,
            opacity: !hasLocation ? 0.4 : pressed ? 0.7 : 1,
          },
        ]}
      >
        <Text style={[styles.buttonText, { color: theme.onPrimary }]}>Open in Maps</Text>
      </Pressable>

      <Pressable
        onPress={confirmDelete}
        accessibilityRole="button"
        style={({ pressed }) => [styles.deleteButton, { opacity: pressed ? 0.6 : 1 }]}
      >
        <Text style={[styles.deleteText, { color: theme.danger }]}>Delete spot</Text>
      </Pressable>
    </ScrollView>
  );
}

function Field({
  label,
  value,
  theme,
  big,
}: {
  label: string;
  value: string;
  theme: ReturnType<typeof useTheme>;
  big?: boolean;
}) {
  return (
    <View style={styles.field}>
      <Text style={[styles.label, { color: theme.muted }]}>{label}</Text>
      <Text style={[big ? styles.bigValue : styles.value, { color: theme.text }]} selectable>
        {value}
      </Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: { padding: 16, gap: 16 },
  center: { flex: 1, alignItems: "center", justifyContent: "center" },
  card: { borderWidth: 1, borderRadius: 16, padding: 18, gap: 18 },
  notice: { borderWidth: 2, borderRadius: 16, padding: 16, gap: 6 },
  noticeTitle: { fontSize: 19, fontWeight: "700" },
  field: { gap: 4 },
  label: { fontSize: 14, fontWeight: "600", textTransform: "uppercase" },
  value: { fontSize: 18 },
  bigValue: { fontSize: 26, fontWeight: "700" },
  button: {
    minHeight: 64,
    borderRadius: 16,
    alignItems: "center",
    justifyContent: "center",
  },
  buttonText: { fontSize: 20, fontWeight: "700" },
  deleteButton: { alignItems: "center", padding: 14 },
  deleteText: { fontSize: 17, fontWeight: "600" },
});

src/lib/location.ts

import * as Location from "expo-location";
import { Linking, Platform } from "react-native";

export type Coords = {
  latitude: number;
  longitude: number;
  accuracy: number | null;
};

export class PermissionDeniedError extends Error {}

function timeout(ms: number) {
  return new Promise<never>((_, reject) =>
    setTimeout(() => reject(new Error("Location timed out")), ms),
  );
}

/**
 * Gets the current position. In basements GPS is often weak, so we give up
 * after a while and fall back to the last known position. Returns null if
 * no position is available at all.
 */
export async function getCurrentCoords(): Promise<Coords | null> {
  let granted = false;
  try {
    const { status } = await Location.requestForegroundPermissionsAsync();
    granted = status === "granted";
  } catch {
    // e.g. a browser without geolocation, or a page not served over https
  }
  if (!granted) throw new PermissionDeniedError();

  try {
    const pos = await Promise.race([
      Location.getCurrentPositionAsync({ accuracy: Location.Accuracy.High }),
      timeout(15000),
    ]);
    return {
      latitude: pos.coords.latitude,
      longitude: pos.coords.longitude,
      accuracy: pos.coords.accuracy ?? null,
    };
  } catch {
    const last = await Location.getLastKnownPositionAsync().catch(() => null);
    if (!last) return null;
    return {
      latitude: last.coords.latitude,
      longitude: last.coords.longitude,
      accuracy: last.coords.accuracy ?? null,
    };
  }
}

export async function openInMaps(lat: number, lng: number, label: string) {
  const q = encodeURIComponent(label);
  const google = `https://www.google.com/maps/search/?api=1&query=${lat},${lng}`;
  const url = Platform.select({
    ios: `https://maps.apple.com/?ll=${lat},${lng}&q=${q}`,
    android: `geo:${lat},${lng}?q=${lat},${lng}(${q})`,
    default: google,
  });
  try {
    await Linking.openURL(url);
  } catch {
    await Linking.openURL(google);
  }
}

src/lib/spots.ts

import Storage from "expo-sqlite/kv-store";

export type Spot = {
  id: string;
  /** null when the phone couldn't get a location (e.g. deep in a basement) */
  latitude: number | null;
  longitude: number | null;
  /** accuracy radius in metres, if known */
  accuracy: number | null;
  savedAt: number;
  note: string;
};

const KEY = "spots";

export async function loadSpots(): Promise<Spot[]> {
  const raw = await Storage.getItem(KEY);
  if (!raw) return [];
  try {
    const parsed = JSON.parse(raw);
    return Array.isArray(parsed) ? parsed : [];
  } catch {
    return [];
  }
}

async function saveSpots(spots: Spot[]) {
  await Storage.setItem(KEY, JSON.stringify(spots));
}

export async function getSpot(id: string): Promise<Spot | undefined> {
  const spots = await loadSpots();
  return spots.find((s) => s.id === id);
}

export async function addSpot(spot: Omit<Spot, "id">): Promise<Spot> {
  const newSpot: Spot = {
    ...spot,
    id: `${spot.savedAt}-${Math.random().toString(36).slice(2, 8)}`,
  };
  const spots = await loadSpots();
  // newest first
  await saveSpots([newSpot, ...spots]);
  return newSpot;
}

export async function deleteSpot(id: string) {
  const spots = await loadSpots();
  await saveSpots(spots.filter((s) => s.id !== id));
}

export function formatTime(timestamp: number) {
  return new Date(timestamp).toLocaleString(undefined, {
    weekday: "short",
    day: "numeric",
    month: "short",
    hour: "numeric",
    minute: "2-digit",
  });
}

src/lib/theme.ts

import { useColorScheme } from "react-native";

const light = {
  background: "#F4F6F8",
  card: "#FFFFFF",
  text: "#111418",
  muted: "#5B6470",
  border: "#D5DAE0",
  primary: "#1F7AE0",
  onPrimary: "#FFFFFF",
  danger: "#C62828",
};

const dark: typeof light = {
  background: "#0E1114",
  card: "#1A1F25",
  text: "#F2F4F7",
  muted: "#9AA4B0",
  border: "#2E353D",
  primary: "#4C9BF0",
  onPrimary: "#FFFFFF",
  danger: "#EF6B6B",
};

export type Theme = typeof light;

export function useTheme(): Theme {
  return useColorScheme() === "dark" ? dark : light;
}

metro.config.js

// Learn more https://docs.expo.dev/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');

/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);

// expo-sqlite on web loads SQLite as a WebAssembly file.
if (!config.resolver.assetExts.includes('wasm')) {
  config.resolver.assetExts.push('wasm');
}

// expo-sqlite on web needs SharedArrayBuffer, which browsers only allow
// on cross-origin isolated pages. These headers apply to the dev server only.
const enhanceMiddleware = config.server.enhanceMiddleware;
config.server.enhanceMiddleware = (middleware, metroServer) => {
  const enhancedMiddleware = enhanceMiddleware
    ? enhanceMiddleware(middleware, metroServer)
    : middleware;
  return (req, res, next) => {
    res.setHeader('Cross-Origin-Embedder-Policy', 'credentialless');
    res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
    return enhancedMiddleware(req, res, next);
  };
};

module.exports = config;

Common mistakes (real)

Mistake What you see (real) Why Fix
Text straight inside <View> Unexpected text node: I parked at B2, pillar 14. A text node cannot be a child of a <View>. A phone has no HTML; text needs its own component Wrap all text in <Text>
Plugin listed in app.json, package not installed Failed to resolve plugin for module "expo-sqlite" ... Do you have node modules installed? The AI couldn't run the install npx expo install expo-location expo-sqlite
expo-sqlite in the web preview Unable to resolve module ./wa-sqlite/wa-sqlite.wasm Metro doesn't bundle .wasm by default metro.config.js: add wasm, send the two headers (Expo SQLite docs)
Changing metro.config.js without restarting (the old error stays) "Metro only reads its config at startup" npx expo start --clear
Alert.alert for important messages Nothing on the web react-native-web: static alert() {} Show the message on the screen
Saving only after the location succeeds "Don't allow" → note lost Saving was inside the try, after the location Location is a bonus: save the note and time anyway
Pushing the user to Settings after "no" (pressure) Android's guide: accept the user's choice Explain on screen; keep the app usable
Trusting the AI's "it works in Expo Go" (not tested) It never ran on a phone Test on a real phone, every path

Mini project

  1. Create a project with npx create-expo-app@latest, then npm run reset-project.
  2. Ask your AI tool for a two-screen app that uses one device feature (location, camera or photos), with Expo Router, saving data on the phone.
  3. Install what it asks for with npx expo install, run npx tsc --noEmit, then npx expo start.
  4. Test on your phone (Expo Go or a development build, per Expo's docs for your SDK) and in the web preview: allow, don't allow, airplane mode, close and reopen the app.
  5. For every path that breaks, give the AI the exact error or exact behaviour, one problem at a time, and commit after each fix.
  6. Fix Park Buddy's "Delete spot" on the web: replace the pop-up with an on-screen confirm.

Practice questions

  1. Why can't Asha just build one normal app and run it on both phones?
Answer

Android and iPhone build screens from different native parts (ViewGroup/TextView vs UIView/UITextView), so a native app is built separately for each; building for iPhone also needs a Mac. React Native lets you write once and creates each phone's own views at runtime.

  1. What does Expo add on top of React Native?
Answer

Tools around it: creating a project (create-expo-app), running it (npx expo start, the QR code, Expo Go, the web preview), libraries for phone features (expo-location, expo-sqlite), Expo Router, and building the final app.

  1. Fix this so it works on a phone: <View>Hello Papa</View>
Answer

<View><Text>Hello Papa</Text></View> — loose text can't be a child of a View; import Text from react-native.

  1. In Expo Router, which file is the screen at /spot/42?
Answer

src/app/spot/[id].tsx — [id] is a dynamic part; inside the screen, useLocalSearchParams() gives id = "42".

  1. What does this print? (Run it with Node.)
const stack = ["/"];
stack.push("/spot/1"); stack.push("/spot/1/map"); stack.pop();
console.log(stack.join(" > "));
Answer

/ > /spot/1 — two pushes, one pop (Back).

  1. When should an app ask for location permission?
Answer

In context: when the user starts to use the feature that needs it (here, tapping "I parked here"), with a clear reason, not when the app first opens.

  1. The user taps "Don't allow". List two things a good app does.
Answer

Keeps working as far as it can (save the note and time), and tells the user plainly what didn't happen (the place wasn't saved), without pressuring them to change their choice.

  1. Why did nothing at all happen in the browser in version 1?
Answer

The only message was an Alert.alert pop-up, and react-native-web's Alert is static alert() {}, an empty function. And the save never happened because it was after the location step in the same try.

  1. You changed the permission text in app.json. Will a reload on the phone show the new text?
Answer

No. It goes into the native app's settings (Info.plist on iPhone); Expo's docs say Info.plist changes "cannot be updated over-the-air". You need a new build.

  1. Why might the saved location be wrong even when permission is allowed?
Answer

GPS is weak underground; the phone may only know roughly where the mall is (the app uses a 15-second timeout, then the last known position). That's why the note matters.

Quiz

Papa taps "Don't allow" for location. What should Park Buddy do?

  • A) Close the app
  • B) Ask again every time he opens it
  • C) Save the note and time, and say the place wasn't saved
  • D) Keep sending him to the Settings app
Answer

C. Android's guide: degrade gracefully so the user can keep using the app, and accept their choice. The note and time still find the scooter; say clearly that the place wasn't saved.

Interview questions

  1. How does React Native differ from a web page in a phone's browser? React Native components become the platform's own native views at runtime (View → ViewGroup/UIView), so the app is installed and looks and behaves like other apps, with access to device features through native modules; a web page renders HTML in the browser.
  2. React Native/Expo vs Flutter? Both build Android and iOS apps from one codebase. React Native uses JavaScript/TypeScript and React components that map to native views; Flutter uses Dart and its own rendering engine. Pick by team skills and the libraries you need.
  3. What is file-based routing? The folder structure defines the screens: each file in app/ is a route; [id] makes a dynamic segment; _layout files define navigators such as a stack or tabs.
  4. Best practices for runtime permissions? Request only what you need, in context, with a clear reason; handle denial gracefully; don't block the UI or pressure users; remember a denial can become permanent; set the platform usage descriptions.
  5. Why can't you fully trust AI-written mobile code? The agent can't run it on devices, can't see OS dialogs, works from training data while SDKs change every release, and the same code behaves differently on iOS, Android and web. Every path needs testing on a real device.
  6. What's the difference between Expo Go and a development build? Expo Go is a ready-made app for trying projects quickly, with a fixed set of native modules; a development build is your own app with Expo's developer tools, supporting custom native modules and intended for real projects.

Glossary

Term Meaning (plain words) Example
Native app An app built from the phone's own parts, installed like any other app Park Buddy on Papa's Android
React Native A framework to write phone apps once in JavaScript; it creates each phone's native views at runtime <View> → ViewGroup / UIView
Expo Tools around React Native to create, run and build apps npx create-expo-app@latest
Flutter Google's framework for apps on many platforms from one codebase, in Dart Same idea, different language
Dart The programming language Flutter uses —
SDK Software development kit: the toolbox of one version Expo SDK 58
Component A building block of the screen <View>, <Text>, <TextInput>
<View> A box that holds other components Like a non-scrolling <div>
<Text> Text on the screen; all text must be inside one <Text>B2, pillar 14</Text>
<TextInput> A box to type in The note box
Native view The phone's own UI part that a component becomes ViewGroup, UIView
Metro Expo's bundler Started by npx expo start
Bundler A program that packs your code into one bundle the app loads Metro
Expo Go Expo's playground app: scan the QR code to open a project on your phone "Scan the QR code above to open in Expo Go."
Development build A build of your own app with Expo's developer tools; supports custom native modules For real projects
QR code A square barcode the phone camera can read Printed by npx expo start
Web preview Running the same app in a browser (w) http://localhost:8081
Screen One whole-display view of an app Home, spot details
Navigation Moving between screens Tap a spot, then Back
Navigation stack Screens kept like a stack of plates: open = push, Back = pop / > /spot/123
Expo Router Expo's file-based router: each file in app/ is a screen src/app/index.tsx = /
Route A screen's address /spot/1794478327016-mnnihq
Dynamic route A route with a fill-in-the-blank part src/app/spot/[id].tsx
_layout.tsx Says how screens are arranged A Stack
Package / native module Add-on code; native modules talk to phone features expo-location, expo-sqlite
npx expo install Installs packages in versions that match your SDK npx expo install expo-location
Config plugin An entry in app.json that changes the native app's settings ["expo-location", {...}]
Typecheck Checking TypeScript types without running the code npx tsc --noEmit
SQLite A small database stored in one file expo-sqlite
Key-value store Storage of values under names, like labelled lockers Storage.setItem("spots", ...)
WebAssembly (.wasm) A fast binary code format browsers can run wa-sqlite.wasm
Device permission The phone asking the user before an app uses private things Location, camera
Foreground While the app is open on screen requestForegroundPermissionsAsync
Usage description The reason text shown with a permission question "Park Buddy uses your location to remember where you parked."
Ask in context Request a permission when the user starts the feature that needs it On tapping "I parked here"
Graceful degradation Keep working as far as possible when something is refused or missing Save note and time without location
Secure context https:// (or localhost): required on the web for location and camera http://localhost:8081
Alert.alert React Native's pop-up dialog; empty on react-native-web 0.21.4 static alert() {}
GPS Satellite positioning; weak underground "within about 12 m" outdoors

Summary

  • Android and iPhone use different native parts; React Native lets you write the app once in JavaScript and creates each phone's own views. Expo is the toolkit around it; Flutter is the same idea in Dart.
  • npx create-expo-app@latest makes a project; npx expo start prints a QR code for Expo Go, and w opens a web preview. Check Expo's docs for which SDK Expo Go supports on a physical device.
  • There's no HTML on a phone: all text goes inside <Text>.
  • Screens form a stack (push, Back = pop); with Expo Router, each file in src/app is a screen and [id] is a dynamic part.
  • Permissions: ask in context, say why, and respect "no". The AI asked at the right moment, but "Don't allow" lost Papa's note, and its pop-up was an empty function on the web. One exact prompt fixed it.
  • AI can't hold a phone and writes from memory when it can't read the docs. You test every path: allow, don't allow, no signal.
  • Next episode: automations, scripts that save hours.