As I'm sure you're aware, installing web apps to your desktop and home screen has become an essential part of our daily digital lives. With the rise of Progressive Web Apps (PWAs), developers can now create enhanced user experiences that rival native mobile apps. In this article, we'll explore how to set up your Rails app for installability as a PWA.
Rails 8: The Future of Swift App Development
With Rails 8 on the horizon, you'll soon be able to create PWA-enabled apps by default. But why wait? You can start building PWAs today and unlock a world of possibilities. PWAs offer features like web push notifications, native badge counters, network connectivity info, and access to native-app-like APIs. This means your users will experience an even more seamless and engaging app experience.
Install Joy of Rails: A Live Demo
Let's take Joy of Rails as an example. As a Rails app itself, you can participate in a live demo by installing it on your desktop or home screen. Try it now and see how easy it is to get started with PWAs!
What Does It Mean for a Web App to Be Installable?
We're not just talking about adding a bookmark to the site; installable PWAs can deeply integrate with your device. This means you can:
- Install like a platform-specific app without an App Store*
- Customize the install process in some browsers
- Get an app icon on the device, alongside native apps
- Launch as a standalone app, rather than a website in a browser
*I haven't tried this yet, but PWAs can also be submitted to various app stores (more info.)
The Power of Progressive Web Apps
As a product developer, I prefer building for the web. With PWAs, you can deliver an app experience without building separate native apps. This is especially important when it comes to updates – with PWAs, your users will always have access to the latest version.
Prerequisites for Making Your App Installable
To make your Rails app installable, there are a few requirements:
- The end user must not already have the app installed
- They must access your application using a supporting browser
- They must pass certain browser-specific heuristics (e.g., interacted with your app and been active for more than 30 seconds in Chromium-based browsers)
Your App's Requirements
To be installable, your Rails app must:
- Serve responses over HTTPS (or HTTP for loopback addresses)
- Register a valid web manifest file in the HTML document
- Minimally declare the following properties:
+ name: the display name of your web app
+ icons: an array of icon data including sizes 192x192 and 512x512
+ start_url: typically, the absolute URL of your app's landing page
+ display: one of fullscreen, standalone, or minimal-ui
+ prefer_related_applications: indicate you don't want to push users to a mobile app instead (set to false)
For more on browser-specific installation criteria, check out these resources:
- [Browser-Specific Installation Criteria](https://www.example.com/install-criteria)
- [Web Manifest Properties](https://www.example.com/web-manifest-properties)
Setting Up Your Rails App
To get your Rails app configured for installability as a PWA, follow these steps:
- Make sure your Rails app is served over HTTPS by checking config/production.rb and forcing requests to HTTPS.
- Register a valid web manifest file in the HTML document and minimally declare the required properties.
By following these steps, you'll be able to create installable PWAs for your users, unlocking a world of possibilities for your web app.