Skip to content
beginner Phase 14 · Server-Side Rendering and PWA

Web App Manifest and Install Prompt

Declare icons and display mode so the app can be installed.

30m
0 problems
Topic Progress 0%

Web App Manifest

The web app manifest declares how your app appears when installed on a device.

Generated Manifest

// public/manifest.webmanifest
{
  "name": "My Angular App",
  "short_name": "MyApp",
  "theme_color": "#1976d2",
  "background_color": "#fafafa",
  "display": "standalone",
  "scope": "/",
  "icons": [
    {
      "src": "assets/icons/icon-72x72.png",
      "sizes": "72x72",
      "type": "image/png"
    },
    {
      "src": "assets/icons/icon-96x96.png",
      "sizes": "96x96",
      "type": "image/png"
    },
    {
      "src": "assets/icons/icon-128x128.png",
      "sizes": "128x128",
      "type": "image/png"
    },
    {
      "src": "assets/icons/icon-192x192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "assets/icons/icon-512x512.png",
      "sizes": "512x512",
      "type": "image/png"
    }
  ]
}

Manifest Properties

Property Purpose
name Full app name
short_name Short name for the launcher icon
theme_color Browser toolbar color
background_color Splash screen background
display Display mode (standalone, fullscreen, minimal-ui, browser)
scope Navigation scope of the app
start_url URL to launch when opened from the launcher
icons App icons in various sizes

Display Modes

Mode Behavior
standalone Looks like a native app (no browser UI)
fullscreen Hides all system UI
minimal-ui Minimal browser controls
browser Standard browser tab

Install Prompt and Maskable Icons

Browsers offer an install prompt when the manifest and service worker checks pass.

Install Prompt Requirements

  1. Manifest — Valid web app manifest with name, icons, start_url
  2. Service Worker — Registered and active
  3. HTTPS — Served over HTTPS (except localhost)
  4. Engagement — User has interacted with the domain (Chrome heuristic)

Listening for the Install Prompt

@Component({
  selector: 'app-root',
  template: `
    <button *ngIf="showInstallButton" (click)="install()">
      Install App
    </button>
  `,
})
export class AppComponent {
  private deferredPrompt: any;
  showInstallButton = false;

  @HostListener('window:beforeinstallprompt', ['$event'])
  onBeforeInstallPrompt(event: Event): void {
    event.preventDefault();
    this.deferredPrompt = event;
    this.showInstallButton = true;
  }

  install(): void {
    if (this.deferredPrompt) {
      this.deferredPrompt.prompt();
      this.deferredPrompt.userChoice.then((choice: any) => {
        if (choice.outcome === 'accepted') {
          console.log('User installed the app');
        }
        this.deferredPrompt = null;
        this.showInstallButton = false;
      });
    }
  }
}

Maskable Icons

Maskable icons ensure the launcher does not crop your logo on Android devices:

{
  "src": "assets/icons/maskable-512x512.png",
  "sizes": "512x512",
  "type": "image/png",
  "purpose": "maskable"
}

The purpose: "maskable" property tells the browser to use the full icon area, with a safe zone in the center.

Generating Icons

# Use Angular CLI to generate icons from a source image
ng generate @angular/pwa:icons --source=logo.png

Or use online tools like:

Quiz

1. What does the web app manifest declare?

Question 1 options

2. What is the standalone display mode?

Question 2 options

3. What are maskable icons?

Question 3 options

Flashcards

Question

What does the manifest declare?

Answer

App metadata: name, icons, display mode, colors, start_url.

Question

What is standalone display mode?

Answer

Looks like a native app without browser UI.

Question

What are maskable icons?

Answer

Icons that adapt to launcher shapes without cropping. purpose: maskable.

Revision Notes

Key Takeaways

  • 1. Manifest declares app metadata for installation
  • 2. standalone mode hides browser UI
  • 3. Install prompt requires manifest + service worker + HTTPS
  • 4. Maskable icons prevent launcher cropping

Interview Tips

  • • Explain manifest properties
  • • Be ready to describe install prompt requirements
  • • Mention maskable icons for Android compatibility

Cheat Sheet

Web App Manifest Cheat Sheet

Manifest properties:

  • name, short_name
  • theme_color, background_color
  • display: standalone
  • icons (multiple sizes)

Install requirements:

  1. Valid manifest
  2. Service worker registered
  3. HTTPS
  4. User engagement

Maskable icons:

{ "purpose": "maskable" }

Continue Learning