Skip to content

Update service worker when new version is detected #3667

@Rich-Harris

Description

@Rich-Harris

Describe the problem

With #3412, SvelteKit can detect when new versions of the app have been deployed. It would be useful if the service worker was updated when that happens, if one exists.

Describe the proposed solution

Inside the code that checks for updates, something like this:

const registration = await navigator.serviceWorker.getRegistration(base || '/');

if (registration) {
  registration.update();
}

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions