What is a Web App Manifest?
A critical aspect of Progressive Web Apps (PWAs) is their ability to provide an app-like experience on mobile and desktop devices.
One key component that enables this behavior is the Web App Manifest—a JSON
file that defines how the PWA appears and behaves when installed on a user’s device.
Defining the Web App Manifest
The Web App Manifest is a simple JSON file that provides metadata about a web application. It allows a PWA to be installed on a device and defines how it should appear in the app launcher or home screen.
The manifest file typically includes the following properties:
- name: The full name of the application.
- short_name: A shorter version of the name for display in tight spaces.
- start_url: The URL that should load when the app is opened.
- display: Defines how the app should appear (standalone, fullscreen, minimal-ui, etc.).
- background_color: The background color of the splash screen.
- theme_color: The color of the browser UI when the app is loaded.
- icons: An array of images representing the app icon at different resolutions.
A basic Web App Manifest looks like this:
{
"name": "Rails PWA",
"short_name": "PWA",
"start_url": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#ff5722",
"icons": [
{
"src": "/assets/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/assets/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
How the Manifest Enhances PWAs
By defining this manifest, the PWA can:
- Be installed on a user's home screen or desktop.
- Open in a standalone mode without the browser UI.
- Display a custom splash screen when launching.
- Maintain a consistent theme and icon across devices.