Building a Progressive Web App with Remix

Transform your Remix application into an installable, offline-capable PWA with service workers, manifests, and advanced caching strategies.

Understanding Progressive Web Apps

Progressive Web Apps (PWAs) represent a powerful convergence of web and native application experiences. By leveraging modern web capabilities, PWAs deliver app-like experiences directly through the browser while maintaining the discoverability and accessibility that makes the web unique. Building a PWA with Remix combines the framework's server-first architecture with powerful offline capabilities, creating applications that work seamlessly regardless of network conditions.

Remix, a full-stack web framework built on top of React, provides an ideal foundation for PWA development. Its focus on web standards, progressive enhancement, and server-side rendering aligns perfectly with PWA requirements. The remix-pwa package extends Remix with comprehensive PWA support, enabling developers to add service workers, web app manifests, and offline functionality with minimal configuration.

What Makes an Application a PWA

A Progressive Web App is not a separate technology but a set of web standards and APIs that, when implemented together, create an enhanced web experience:

  • Web App Manifest: A JSON file providing browser information about your application, including icons, colors, and display mode
  • Service Workers: JavaScript files running in the background, intercepting network requests and enabling sophisticated caching
  • HTTPS: Required security baseline for all PWA features

Benefits of PWAs

  • Frictionless Installation: No app store required, users install with a single tap
  • Offline Functionality: Works without internet connectivity
  • Cross-Platform: Single codebase works on any device with a modern browser
  • Push Notifications: Re-engage users with timely updates

For teams working across multiple platforms, PWAs complement our mobile app development services by providing an alternative installation method without the complexity of native app stores.

Why Remix Is Ideal for PWA Development

Server-First Architecture

Remix's SSR produces immediately available HTML, providing a foundation for fast, reliable PWA experiences

Web Standards Focus

Built on standard web APIs that align naturally with PWA requirements

Predictable Data Flow

Remix's data loading patterns work harmoniously with service worker caching strategies

Progressive Enhancement

Applications work without JavaScript first, then enhance with PWA capabilities

Setting Up Your Remix Project for PWA

Installing remix-pwa

The remix-pwa package provides comprehensive PWA support for Remix applications with minimal configuration:

npm install remix-pwa

Configuration Steps

  1. Install the package and any necessary dependencies
  2. Create service worker entry in your public directory
  3. Configure client entry to register the service worker
  4. Create manifest.json with app metadata and icons

The package handles service worker registration, provides sensible caching defaults, and offers a clean API for customizing behavior.

Project Structure

app/
 entry.client.tsx # Register service worker here
 entry.server.tsx
public/
 service-worker.ts # Your service worker code
 manifest.json # Web app manifest
 icons/ # PWA icons at various sizes

Organizing your project for PWA development requires attention to where different assets and configurations live. The service worker file resides in your public directory, making it accessible at the root of your domain. Icons used in the web app manifest should be optimized for different device requirements, with multiple sizes provided to ensure crisp display on all devices.

After configuring PWA features, your Remix application automatically benefits from offline capabilities. The setup integrates seamlessly with existing React development practices, allowing your team to leverage existing expertise while adding progressive enhancement.

Creating the Web App Manifest

The web app manifest is essential for PWA installability. It tells the browser how your app should appear and behave when installed. This JSON file provides the browser with essential information about your application, including icons, colors, display mode, and the start URL.

Essential Manifest Fields

FieldPurpose
nameFull application name for app launchers
short_nameShorter name for space-constrained contexts
start_urlURL loaded when launching the PWA
displayUI mode: standalone, fullscreen, or minimal-ui
theme_colorColors browser UI to match your app
background_colorSplash screen and loading background
iconsArray of icon objects with sizes

Example Manifest

{
 "name": "My Remix PWA",
 "short_name": "Remix PWA",
 "start_url": "/",
 "display": "standalone",
 "theme_color": "#764abc",
 "background_color": "#ffffff",
 "icons": [
 { "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
 { "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any maskable" }
 ]
}

Icon Requirements

Provide icons at multiple sizes: 72, 96, 128, 144, 152, 192, 384, and 512 pixels. Maskable icons should include padding to ensure visibility on devices with different icon shapes. All icons should be square PNG files without transparency. The icons array in your manifest references these image files with their sizes and purpose.

The display field controls how the application appears when launched. Using "standalone" removes browser UI elements, creating an app-like experience. Theme colors affect how native browser UI elements appear within your PWA, providing visual consistency between the browser experience and the installed app experience.

A well-configured manifest is a critical component of modern web applications, enabling your users to install your application directly to their devices without app store friction.

Implementing Service Workers

Service Worker Registration

Service workers run in the background, intercepting requests and enabling caching strategies. Registration typically occurs in your client-side entry point:

// In entry.client.tsx
if ('serviceWorker' in navigator) {
 window.addEventListener('load', () => {
 navigator.serviceWorker.register('/service-worker.js')
 .then(registration => {
 console.log('SW registered:', registration.scope);
 })
 .catch(error => {
 console.log('SW registration failed:', error);
 });
 });
}

Once registered, the service worker moves through three lifecycle states: installing, activated, and redundant. Scope determines which requests the service worker can intercept, with files at the root intercepting requests for any URL within your application.

Caching Strategies

StrategyBehaviorBest For
Cache FirstCheck cache before networkStatic assets, images, fonts
Network FirstTry network, fallback to cacheAPI responses, dynamic content
Stale While RevalidateServe cache, update in backgroundModerately dynamic content

Remix-Specific Caching

Remix applications benefit from strategy combinations. Static assets use Cache First with long durations. API responses use Network First with appropriate cache lengths. HTML documents may use Stale While Revalidate or a configured variant that respects Remix's caching headers.

// Example service worker strategy configuration
const strategies = {
 '/assets/*': 'cache-first',
 '/api/*': 'network-first',
 '/': 'stale-while-revalidate'
};

Route caching targets the initial HTML document returned by Remix loaders. By caching these responses, your service worker can serve previously rendered pages without making network requests. Data caching complements document caching by storing responses from Remix loaders, providing immediate page loads while ensuring content remains current.

Service worker caching complements our performance optimization services by ensuring fast load times even on unreliable networks.

Push Notifications

Enable re-engagement through browser notifications:

  1. Request permission when user demonstrates intent
  2. Subscribe user and send subscription to your server
  3. Send notifications via a push service (FCM, Web Push)
  4. Handle in service worker with push event listeners
// Request permission
Notification.requestPermission().then(permission => {
 if (permission === 'granted') {
 // Subscribe to push
 registration.pushManager.subscribe({
 userVisibleOnly: true,
 applicationServerKey: vapidPublicKey
 });
 }
});

Server-side notification delivery requires integration with a push service like Firebase Cloud Messaging or the Web Push protocol. Service workers handle the delivery of notifications on the client side, listening for push events and displaying notifications through the browser's notification API.


Background Sync

Background Sync allows your PWA to defer actions until the user has a stable network connection:

// Register sync
navigator.serviceWorker.ready.then(registration => {
 registration.sync.register('send-data');
});

// Handle in service worker
self.addEventListener('sync', event => {
 if (event.tag === 'send-data') {
 // Send deferred data
 }
});

Error handling is essential for Background Sync implementations. Network requests made during sync events may still fail, and your implementation should handle these failures gracefully.

Testing and Debugging PWAs

Browser Developer Tools

Chrome DevTools Application tab provides comprehensive PWA debugging capabilities:

  • Service Workers panel: View, update, and debug active service workers
  • Storage inspection: See cached resources and storage usage
  • Manifest viewer: Verify manifest configuration
  • Network monitoring: Track cache vs network requests

The Service Workers panel displays all registered service workers and their current status. From this panel, you can inspect the source code of active service workers, view console output, and manually update or unregister service workers. Storage inspection tools show what your PWA has cached, including both service worker caches and other storage mechanisms.

Lighthouse Auditing

Lighthouse provides automated auditing for PWA features, checking your application against established criteria for progressive web apps:

  • Valid web app manifest with required fields
  • Service worker registration and offline functionality
  • HTTPS usage and security requirements
  • Icons at appropriate sizes

Lighthouse provides specific recommendations for fixing any issues it finds, including links to relevant documentation. Regular Lighthouse auditing during development helps catch PWA issues early, before they become embedded in your codebase.

Common Issues

IssueSolution
Service worker not registeringCheck file location and HTTPS
Cache not updatingUse cache versioning or skipWaiting
Icons not showingVerify manifest icon references
Offline not workingCheck cache strategies and fallbacks

Our team uses comprehensive testing methodologies as part of our quality assurance process to ensure PWAs perform reliably across all devices and network conditions.

Frequently Asked Questions

Ready to Transform Your Web App?

Our team specializes in building modern web applications with advanced capabilities like Progressive Web Apps. Contact us to discuss how we can enhance your application with PWA features.

Sources

  1. LogRocket: Building a progressive web app in Remix - Comprehensive technical guide covering service workers, manifest configuration, caching strategies, and offline capabilities using the remix-pwa package.

  2. DEV Community: Progressive Web Apps & Remix - Overview of PWA and Remix combination, explaining SSR-first caching mentality and service worker registration patterns.