๐Ÿ“š Sanjay's Study Notes Home Roadmap HTML CSS JavaScript TypeScript Node SQL & Prisma React Tailwind Auth Apps Git & Deploy

10 ยท Desktop & Mobile โ€” one skillset, more screens (optional phase)

By Phase 9 the Library runs in any browser. This optional phase shows how the SAME JavaScript/TypeScript/React skillset also ships desktop installers and phone apps. Mostly a read-and-understand phase โ€” build it only if a real need appears.

1. The map โ€” where code can run

TargetToolWhat it really isFamous examples
BrowserReact (done)your Phase 6 appevery website
Desktop (Win/Mac/Linux)Electronyour web app + its own private Chrome + Node, zipped into an installerVS Code, WhatsApp Desktop, Slack, Discord
Phone (Android/iOS)React NativeReact components that render REAL native buttons/lists โ€” not a webpageInstagram, Discord mobile, Shopify
Why these exist at all Before them, desktop meant C++/C#, iOS meant Swift, Android meant Kotlin โ€” three more languages, three codebases, three teams. Electron (2013, built FOR the Atom editor) and React Native (2015) let web teams reuse what they have. The trade: bigger downloads and more memory than true native. For most business apps โ€” including a library system โ€” nobody notices.

2. Electron in one picture

Two processes, and you know both already An Electron app runs your React build inside a bundled Chromium window (the renderer โ€” browser world, DOM rules apply) plus a main process in Node (files, menus, tray โ€” Node world, ยง1 of the Node notes). The two talk over IPC messages โ€” request/response again, just inside one app instead of over a network. VS Code โ€” the editor you've used since Phase 0 โ€” is exactly this. You've been living inside an Electron app the whole course.
When the Library would want it A front-desk machine that must work offline-first, auto-start with Windows, and print receipts โ€” that's the Electron use case. A URL on the desk computer covers everything else with zero extra code.

3. React Native in one picture

// same mental model, different vocabulary โ€” no DOM on a phone
<View style={styles.row}>              // โ† div
    <Text>{book.title}</Text>          // โ† the ONLY place text may live
    <Pressable onPress={borrow}>       // โ† button/onClick
        <Text>Borrow</Text>
    </Pressable>
</View>
What transfers, what changes Transfers untouched: components, props, useState/useEffect, the no-mutation rule, Zustand store, fetch to your Fastify API, all your TypeScript. Changes: HTML tags โ†’ View/Text/Pressable, CSS files โ†’ style objects, and there's no localStorage (AsyncStorage instead). The thinking โ€” UI = f(state) โ€” is identical; that's the point of having learned React first. Tooling: Expo makes dev painless (scan a QR code, the app runs on your real phone).
The one server change a phone forces On your phone, localhost:3000 means the phone itself โ€” not your PC. The phone must call your PC's network address (e.g. 192.168.1.5:3000), and later a real deployed URL. First lesson of leaving the machine: localhost was always "this machine", and now "this machine" changed. Phase 10 makes the API reachable from anywhere, properly.

4. How to choose (the pro's checklist)

SituationAnswer
Works fine as a website?Ship the website. Seriously โ€” most "we need an app" requests don't.
Desk machine, offline, printers, auto-startElectron
Users need it in their pocket, push notifications, cameraReact Native
Just want a home-screen icon + offline cachePWA โ€” a website with a manifest; smallest effort of all

5. The mental model to keep

IdeaOne line to remember
Electronyour web app + private Chrome + Node in an installer โ€” VS Code is one
React NativeReact thinking, native widgets โ€” View/Text/Pressable instead of div/span/button
What carries overeverything conceptual: components, state, store, fetch, TS
localhost lesson"this machine" changes meaning when the app leaves your machine
Default answera good website first; wrap it only for a reason

โ† Prev: Auth  ยท  Back to contents  ยท  Next: Git & Deployment โ†’