From 0978a99428681dd5be1e6f22241f3bc9ecbd6e11 Mon Sep 17 00:00:00 2001 From: Manuel Bach <49973666+mil7@users.noreply.github.com> Date: Wed, 2 Apr 2025 13:42:11 +0200 Subject: [PATCH] Update auto-update.md docs: approach to simplify chapter --- guide/auto-update.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/guide/auto-update.md b/guide/auto-update.md index af8e2b1..eb55572 100644 --- a/guide/auto-update.md +++ b/guide/auto-update.md @@ -6,17 +6,18 @@ outline: deep # Automatic reload With this behavior, once the browser detects a new version of your application, then, it will update the caches and will reload any browser windows/tabs with the application opened automatically to take the control. - -::: warning -In order to reload all client tab/window, you will need to import any virtual module provided by the plugin: if you're not using any virtual, there is no way to interact with the application ui, and so, any client tab/window will not be reloaded (the old service worker will be still controlling the application). - -Automatic reload is not automatic page reload, you will need to use the following code in your application entry point if you want **automatic page reload**: +You will need to use the following code in your application entry point: ```js import { registerSW } from 'virtual:pwa-register' -registerSW({ immediate: true }) +registerSW() ``` + +::: info +In order to reload the client's tab/window, you will need to import the virtual module provided by this plugin. +If you're not using any virtual modules, there is no way to interact with the application ui, and so, any client tab/window will not be reloaded. +The old service worker will be still controlling the application up until the next time the PWA has been reopened in the client. ::: The disadvantage of using this behavior is that the user can lose data in any browser windows/tabs in which the application is open and is filling in a form.