Skip to content

Commit a402d50

Browse files
authored
docs: clarify version management feature (#8941)
closes #8697
1 parent 74a1308 commit a402d50

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

.changeset/quiet-boats-add.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
docs: clarify version management feature

packages/kit/types/index.d.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,23 @@ export interface KitConfig {
520520
config?: (config: Record<string, any>) => Record<string, any> | void;
521521
};
522522
/**
523-
* Client-side navigation can be buggy if you deploy a new version of your app while people are using it. If the code for the new page is already loaded, it may have stale content; if it isn't, the app's route manifest may point to a JavaScript file that no longer exists. SvelteKit solves this problem by falling back to traditional full-page navigation if it detects that a new version has been deployed, using the `name` specified here (which defaults to a timestamp of the build).
523+
* Client-side navigation can be buggy if you deploy a new version of your app while people are using it. If the code for the new page is already loaded, it may have stale content; if it isn't, the app's route manifest may point to a JavaScript file that no longer exists.
524+
* SvelteKit helps you solve this problem through version management.
525+
* If SvelteKit encounters an error while loading the page and detects that a new version has been deployed (using the `name` specified here, which defaults to a timestamp of the build) it will fall back to traditional full-page navigation.
526+
* Not all navigations will result in an error though, for example if the JavaScript for the next page is already loaded. If you still want to force a full-page navigation in these cases, use techniques such as setting the `pollInverval` and then using `beforeNavigate`:
527+
* ```html
528+
* /// +layout.svelte
529+
* <script>
530+
* import { beforeNavigate } from '$app/navigation';
531+
* import { updated } from '$app/stores';
532+
*
533+
* beforeNavigate(({ willUnload, to }) => {
534+
* if ($updated && !willUnload && to?.url) {
535+
* location.href = to.route.url.href;
536+
* }
537+
* });
538+
* </script>
539+
* ```
524540
*
525541
* If you set `pollInterval` to a non-zero value, SvelteKit will poll for new versions in the background and set the value of the [`updated`](/docs/modules#$app-stores-updated) store to `true` when it detects one.
526542
*/

0 commit comments

Comments
 (0)