openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Prompt users to install our app (PWA/TWA)

Open RayBB opened this issue 1 year ago • 7 comments

Feature Request

Problem / Opportunity

Open Library sees significant (and growing) mobile traffic, as global internet access continues to shift toward smartphones. However, the web experience on mobile browsers lacks the persistent visibility and ease-of-return that native-like apps provide. Users who discover Open Library to borrow a book may not return after their session ends, as there's no visual cue (e.g., app icon in the drawer) to remind them of the service. This contributes to low retention despite high initial engagement. Without an installed Progressive Web App (PWA) or Trusted Web Activity (TWA) wrapper, users must re-type URLs, navigate bookmarks, or rely on search engines to return—friction that reduces repeat visits.

Mobile users are app-oriented: installing an app creates a persistent reminder and seamless re-entry point. An Open Library PWA/TWA would:

Appear in the user's app drawer as a visual nudge ("Oh, let me check if they have that book"). Enable faster load times, offline access (where supported), and push notifications (future potential). Align with modern web best practices while providing an app-like experience without App Store/Google Play distribution hurdles.

Impact Hypothesis: Prompting installation at high-intent moments will increase PWA/TWA adoption, leading to improved user retention (measured via return visits, borrow frequency, and session depth).

Success Metrics

Metric Target Rationale
PWA/TWA Install Rate >5% of prompted mobile users Indicates prompt effectiveness without annoyance
7-Day Retention Increase +10–15% for installers vs. non-installers Core goal: app icon drives return visits
Prompt Dismissal Rate <70% permanent dismissals Users should feel in control

Proposal

Proposed Implementation Options (Ranked by UX Quality)

  1. Best: Contextual Prompt on Book Borrow (Recommended)

    • Trigger: After a user successfully borrows a book on mobile.
    • Message: "Get faster access next time—add Open Library to your home screen!" [Add to Home Screen] [Not now]
    • Rationale: High-intent moment; user has committed to the platform.
  2. Good: Return Visitor Prompt (Cookie-Based)

    • Trigger: User returns to the site (2+ sessions) and hasn’t seen prompt in 30+ days.
    • Use localStorage or cookie to suppress after dismissal/install.
    • Avoids first-visit annoyance.
  3. Acceptable: Post-Login / Account Creation

    • Trigger: After login or new account creation.
    • Less ideal than borrow (lower intent signal), but still contextual.
  4. Avoid: Immediate On-Load Prompt

    • Too aggressive; harms first impressions.

Technical Requirements

  • PWA Readiness Audit (Pre-Launch)

    • [ ] Verify manifest.json is valid and includes:
      • name, short_name, icons (192x192, 512x512), start_url, display: standalone
    • [ ] Confirm service worker registers and caches core assets
    • [ ] Test "Add to Home Screen" (A2HS) prompt eligibility:
      • HTTPS
      • User engagement heuristic (Chrome: ~2 interactions)
      • beforeinstallprompt event handling
    • [ ] Validate TWA (Android) packaging if distributed via Google Play
    • [ ] Test on iOS (Safari) and Android (Chrome) — ensure banner appears correctly
  • Prompt UI (Elegant & Native-Feeling)

    <div id="pwa-prompt" class="bottom-sheet">
      <p><strong>Take Open Library with you</strong><br>Add to home screen for quick access anytime.</p>
      <button onclick="installPWA()">Add to Home Screen</button>
      <button onclick="dismissPrompt()" class="text">Not now</button>
    </div>
    
    • Use bottom sheet (mobile-native pattern)
    • Respect deferredPrompt (don’t force; wait for beforeinstallprompt)
    • Set pwa-prompt-dismissed in localStorage with timestamp

Rollout Plan

  1. Phase 1: Audit & Fix

    • Audit PWA/TWA health
    • Fix any manifest, SW, or icon issues
  2. Phase 2: A/B Test (Borrow-Triggered Prompt)

    • 50% of mobile borrow-completers see prompt
    • Track installs, retention, dismissals
  3. Phase 3: Expand (if successful)

    • Add return-visitor logic
    • Explore in-app messaging for logged-in users

Risks & Mitigations

Risk Mitigation
Annoying users Use intent-based triggers + easy dismiss + long re-prompt cooldown
Broken app experience Mandatory pre-launch audit
iOS limitations Clearly brand as "Add to Home Screen" (not "install app")

PS: This is mostly generated by AI based on my discussion about what I'd like to do. I've edited it heavily.

Breakdown

Related files

Refer to this map of common Endpoints: *

Requirements Checklist

Checklist of requirements that need to be satisfied in order for this issue to be closed:

  • [ ]

Stakeholders


Instructions for Contributors

RayBB avatar Nov 11 '25 18:11 RayBB

Hey @RayBB, I'd like to work on this feature

Plan Overview

Files

openlibrary/plugins/openlibrary/js/
├── pwa-prompt.js        # Core prompt logic
├── pwa-integration.js   # Hooks into login/borrow flows
└── service-worker-init.js # Captures beforeinstallprompt

static/css/components/pwa-prompt.less
static/css/js-all.less

pwa-prompt.js – Manages beforeinstallprompt, localStorage tracking, frequency limits, and shows prompts (showAfterBorrow, showAfterLogin, etc.). pwa-integration.js – Auto-detects form submits, AJAX success, and return visits. Exposes window.OpenLibraryPWA. service-worker-init.js – Defers install prompt for contextual triggers. pwa-prompt.less – Responsive bottom sheet/modal using OL tokens.

Logic

  • Auto triggers after borrow/login or for return visitors
  • LocalStorage limits (3 prompts, 30-day cooldown)
  • Skips if installed, dismissed, or not in A/B group

Analytics Fires events: pwa_prompt_shown, pwa_installed, pwa_prompt_dismissed with context info.

Questions

  1. Structure fit OL architecture?
  2. Any specific borrow/login endpoints?
  3. Should I hook into existing analytics?
  4. Anything special for LESS compilation?

Self-contained, zero-config, no breaking changes.

akramcodez avatar Nov 12 '25 07:11 akramcodez

created a draft PR

akramcodez avatar Nov 12 '25 07:11 akramcodez

@lokesh do you have any opinions here on design patterns we can/should follow to do something like this?

RayBB avatar Apr 05 '26 07:04 RayBB

Hi @RayBB , I'd love to work on this! I have experience with PWA implementation including service workers, manifest configuration, and handling beforeinstallprompt. I'd like to start with Phase 1 (audit & fix) and propose a small PR before tackling the prompt UI. Could you assign this to me?

rattnak avatar Apr 06 '26 00:04 rattnak

@rattnak you're assigned.

RayBB avatar Apr 06 '26 04:04 RayBB

This issue raises the question, is the PWA experience substantially better than the non-PWA experience that the work to install an app will be worthwhile for users? or do we need to first work on some of the tech that falls under the umbrella of PWAs?

I had Claude read through our current PWA feature set and provide a summary:

Is it worth installing? Honestly, for the current feature set, the value proposition is thin:

  • The main benefit is standalone display (no browser chrome) and the share target — but the share target just does a search, which you could do by opening the site
  • There's no engagement hook (no notifications, no badge counts for reading lists)
  • The offline experience is just a fallback page — you can't browse cached books offline
  • The shortcuts are convenient but not essential

Where it could become compelling: If OL added offline reading lists (cache borrowed/wishlist books), reading progress sync, or due-date notifications for borrowed books — then the installed app would offer genuinely differentiated value over the browser tab.

lokesh avatar Apr 07 '26 22:04 lokesh

@lokesh that's a fantastic callout. The original idea back when this was created was a discussion about how many people like having an "app" that they can easily click on to go to places they visit frequently.

For many non-techy folks having it installed like an "app" alone is useful even without extra features.

But it's a good question I suppose we should bring it to the team. I'm of the opinion that encouraging people to install the PWA/TWA is a win as long as we remember when someone dismissed it and don't keep nagging them about it.

RayBB avatar Apr 07 '26 23:04 RayBB