Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zastro-service-worker

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zastro-service-worker

An Astro integration that adds service worker functionality to your Astro project, powered by Workbox.

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by350%
Maintainers
0
Weekly downloads
 
Created
Source

Astro Service Worker

An Astro integration that adds service worker functionality to your Astro project, powered by Workbox.

Installation

npm install zastro-service-worker

In theory, you can run

npx astro add zastro-service-worker

Usage

Add the integration to your astro.config.mjs file:

import { defineConfig } from 'astro/config';
import astroServiceWorker from 'zastro-service-worker';

export default defineConfig({
  integrations: [astroServiceWorker()],
});

Configuration

You can customize the service worker behavior by passing options to the integration:

astroServiceWorker({
  userOptions: {
    enableInDevelopment: true, // Enable service worker in development mode
  },
  workboxOptions: {
    // Add custom Workbox options here
  }
})

User Options

  • enableInDevelopment: Boolean (default: false) - Enables the service worker in development mode.
  • customServiceWorker: String (not implemented yet) - Path to a custom service worker file.

Workbox Options

You can pass any valid Workbox options to customize the service worker generation. See the Workbox documentation for available options.

Features

  • Automatic service worker registration
  • Precaching of static assets
  • Runtime caching strategies for different types of requests
  • Background sync for POST requests
  • Customizable caching strategies

Development

By default, a noop service worker is used in development to prevent caching issues. You can enable the full service worker in development by setting enableInDevelopment: true in the user options.

License

MIT

Changelog

  • 0.0.2: Fix README lol
  • 0.0.1: Publish

Keywords

FAQs

Package last updated on 10 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc