Esta página ainda não está disponível em Português, por isso está a ler a versão em inglês.

PWA with Astro and other static site generators

Static sites are the easiest PWAs of all.

Frameworks Iniciante 1 min de leitura Revisado em 27 de nov. de 2026

Static sites make excellent PWAs: every page is a file, so caching is simple and safe.

Astro

npx astro add @vite-pwa/astro
// astro.config.mjs
import { defineConfig } from 'astro/config';
import AstroPWA from '@vite-pwa/astro';
export default defineConfig({
  integrations: [AstroPWA({
    registerType: 'autoUpdate',
    manifest: { name: 'My Site', short_name: 'Site', theme_color: '#5A0FC8', icons: [/* ... */] },
    workbox: { navigateFallback: '/404', globPatterns: ['**/*.{css,js,html,svg,png,ico,txt}'] },
  })],
});

Eleventy, Hugo, Jekyll or any static output

Run the Workbox CLI after your build to generate a worker with a precache list of the output folder:

npx workbox-cli wizard            # once: answers saved to workbox-config.js
npx workbox-cli generateSW workbox-config.js

For large sites, do not precache every page; precache the shell and use a network-first runtime rule for HTML.

Small sites

For a blog or brochure site, a 40-line hand-written worker is enough. Generate one with our service worker generator, add a manifest and icons, and you are done.