When wrapping a habit tracker in Hotwire Native shells, how would you decide which screens stay web, which gain bridge components and which become fully native?
answer
- web by default, native by exception
- bridge components for native chrome
- native for gestures, device APIs, offline
- view_controller (iOS) / uri (Android)
- versioned config and fallback_uri for old builds
basics
~20 sStart with every screen as web, add bridge components where a web screen needs native controls, and rebuild only screens whose interaction, device access or offline needs the web view cannot meet. Path configuration maps those URLs to native screens per build.
solid answer
~50 sI treat native code as a cost to justify. Every screen starts as web, because it ships with a deploy and is built once for three platforms. When a web screen only needs native chrome, such as a Save button in the navigation bar, a menu or a share sheet, a bridge component adds it without rewriting the screen. A screen goes fully native when the web view is the bottleneck: dense gesture-driven interaction like a swipeable weekly streak grid, deep device APIs, offline use, or something users open many times a day where native feel pays back. Even then the switch is server-driven: a path configuration rule maps the URL to a native screen with `view_controller` on iOS or `uri` on Android, `fallback_uri` covers Android builds without it, and versioned remote files keep old builds on the web version. I would revisit the split with usage data.
code
json · 8 lines{
"settings": {},
"rules": [
{ "patterns": [".*"], "properties": { "context": "default" } },
{ "patterns": ["/habits/new$"], "properties": { "context": "modal" } },
{ "patterns": ["/today$"], "properties": { "view_controller": "today" } }
]
}go deeper
Recall that most screens stay web and that some controls or screens can be made native later.
Explain the three tiers and how path configuration maps a URL to a native screen on each platform.
Argue a specific screen's case from interaction, device access, offline needs and usage, and plan versioned rollout with fallbacks.
Own the long-term split: native capacity, release cadence, old-build support and when to revisit, with web as the default.
## The decision is about cost, not capability Hotwire Native can show any screen natively; the question is whether it should. Each fully native screen is written twice (Swift and Kotlin), tested twice, released through two app stores, and kept in step with the web version that browsers still use. Each web screen is written once, ships with a deploy, and looks the same everywhere. The default is therefore **web**, and native work has to earn its place. ## Three tiers | tier | what it is | good fits in a habit tracker | |---|---|---| | web screen | HTML rendered by Rails in a web view | habit list, habit form, settings, account, help, history tables | | web screen plus bridge components | the same HTML, with native controls driven by Stimulus-based components | Save button in the navigation bar, overflow menu for archive and delete, native share sheet for a streak | | native screen | Swift or Kotlin UI mapped to a URL | a swipe-to-check-in daily view used many times a day, a reminder scheduler tied to platform notifications, an offline check-in queue | ## Signals that a screen should go native 1. **Interaction density.** Fast, gesture-heavy UI such as swiping through days, dragging to reorder, or animating a streak where web-view latency is felt. 2. **Device integration.** Platform APIs the web cannot reach well, such as notification scheduling or health data, where a bridge component would be most of the screen anyway. 3. **Offline use.** Web screens need the server for fresh content; a check-in that must work on a plane needs local storage and sync. 4. **Frequency of use.** The screen users open daily is where native polish pays back; the settings page visited twice a year is not. 5. **Stability of the design.** A screen still changing weekly is cheaper as web, because native changes wait for store review and for users to update. The opposite signals keep a screen web: content-heavy pages, forms with server-side validation, admin-like screens, and anything A/B tested or iterated quickly. ## Making the switch server-driven The path configuration makes this incremental: - On iOS a rule such as `{ "patterns": ["/today$"], "properties": { "view_controller": "today" } }` routes the URL to a view controller conforming to `PathConfigurationIdentifiable`. - On Android `"uri": "hotwire://fragment/today"` routes it to a fragment annotated with `@HotwireDestinationDeepLink`, and `fallback_uri` names a destination for builds that do not have it yet. - Remote files versioned per platform (`ios_v1.json`, `ios_v2.json`) let new builds opt in while old builds keep the web page. Because the web page for `/today` keeps existing, browsers, old app builds and the fallback all still work, and rolling back is a configuration change rather than an emergency release. ## Questions I would ask the team - Which screens produce most sessions, and which produce complaints about feel? - Do we have, or want, people who can maintain Swift and Kotlin code long term? - Can the native screen still fetch its data from the same Rails app, for instance a JSON endpoint beside the HTML one, without forking business rules? - What is the oldest app build we must support, and how will its path configuration behave? ## Costs people underestimate - **Parity.** A native screen and its web twin drift unless someone owns both; decide which one is the reference. - **Authentication.** Native screens must share the web view's session or use their own tokens, which is extra work the web screens never needed. - **Analytics and errors.** Native screens need their own instrumentation to stay comparable with the web ones. ## A reasonable first release Ship the habit tracker with every screen web, two or three bridge components (form submit, menu, share), a modal rule for new and edit forms, and native tabs. Measure. Then move the one or two screens that clearly hurt to native, behind versioned path configuration, keeping their web versions alive.
- How do you move a screen to native without breaking users on older app builds?Keep the web page, and point only new builds at the native screen through a new versioned path configuration file, such as `ios_v2.json`. On Android, `fallback_uri` names a destination for builds that lack the new `uri`. Old builds keep their rules and the web screen.
- When is a bridge component better than a native screen?When the screen's content works as HTML and only its controls need to feel native: a navigation-bar button, a menu, a share sheet. The component is small, the page stays one shared implementation, and browsers and old builds degrade to the web controls.
- Going native means rewriting the whole app before launch
- Bridge components are the right tool for offline-first screens
- Once a screen is native, its web version can be deleted safely
- Moving a URL to a native screen needs no versioning because path configuration is global
- Native screens cannot use data from the existing Rails app