Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions guide/auto-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still do not understand this sentence, I admit. I aggressively dropped this sentence.

Without registering the SW in the application nothing is happening here. That the SW installs any new application caches as soon it is triggered to do so happens independently of the registerType.

You will need to use the following code in your application entry point:

```js
import { registerSW } from 'virtual:pwa-register'

registerSW({ immediate: true })
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another bold move because the flag is missleading and has nothing to do with the automatic reload itself but is only used in a very rare case.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question is, should we mention that flag anywhere?

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.
Expand Down