From 38c1b98ab4b609be7194a51d8f4d0d53a1339185 Mon Sep 17 00:00:00 2001 From: "svelte-docs-bot[bot]" <196124396+svelte-docs-bot[bot]@users.noreply.github.com> Date: Fri, 12 Sep 2025 21:52:51 +0000 Subject: [PATCH] sync kit docs --- .../docs/kit/98-reference/10-@sveltejs-kit.md | 364 ++++++++++++++---- 1 file changed, 279 insertions(+), 85 deletions(-) diff --git a/apps/svelte.dev/content/docs/kit/98-reference/10-@sveltejs-kit.md b/apps/svelte.dev/content/docs/kit/98-reference/10-@sveltejs-kit.md index 5b13fb4d7f..70fbba02d2 100644 --- a/apps/svelte.dev/content/docs/kit/98-reference/10-@sveltejs-kit.md +++ b/apps/svelte.dev/content/docs/kit/98-reference/10-@sveltejs-kit.md @@ -494,39 +494,24 @@ The argument passed to [`afterNavigate`](/docs/kit/$app-navigation#afterNavigate
```dts -interface AfterNavigate extends Omit {/*…*/} -``` - -
- -```dts -type: Exclude; -``` - -
- -The type of navigation: -- `enter`: The app has hydrated/started -- `form`: The user submitted a `
` -- `link`: Navigation was triggered by a link click -- `goto`: Navigation was triggered by a `goto(...)` call or a redirect -- `popstate`: Navigation was triggered by back/forward navigation - -
-
- -
- -```dts -willUnload: false; +type AfterNavigate = (Navigation | NavigationEnter) & { + /** + * The type of navigation: + * - `enter`: The app has hydrated/started + * - `form`: The user submitted a `` + * - `link`: Navigation was triggered by a link click + * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect + * - `popstate`: Navigation was triggered by back/forward navigation + */ + type: Exclude; + /** + * Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page. + */ + willUnload: false; +}; ``` -
- -Since `afterNavigate` callbacks are called after a navigation completes, they will never be called with a navigation that unloads the page. -
-
## AwaitedActions @@ -553,21 +538,15 @@ The argument passed to [`beforeNavigate`](/docs/kit/$app-navigation#beforeNaviga
```dts -interface BeforeNavigate extends Navigation {/*…*/} -``` - -
- -```dts -cancel: () => void; +type BeforeNavigate = Navigation & { + /** + * Call this to prevent the navigation from starting. + */ + cancel: () => void; +}; ``` -
- -Call this to prevent the navigation from starting. -
-
## Builder @@ -1581,7 +1560,21 @@ type LoadProperties<
```dts -interface Navigation {/*…*/} +type Navigation = + | NavigationExternal + | NavigationFormSubmit + | NavigationPopState + | NavigationLink; +``` + +
+ +## NavigationBase + +
+ +```dts +interface NavigationBase {/*…*/} ```
@@ -1613,17 +1606,12 @@ Where navigation is going to/has gone to
```dts -type: Exclude; +willUnload: boolean; ```
-The type of navigation: -- `form`: The user submitted a `` -- `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring -- `link`: Navigation was triggered by a link click -- `goto`: Navigation was triggered by a `goto(...)` call or a redirect -- `popstate`: Navigation was triggered by back/forward navigation +Whether or not the navigation will result in the page being unloaded (i.e. not a client-side navigation)
@@ -1631,12 +1619,39 @@ The type of navigation:
```dts -willUnload: boolean; +complete: Promise; ```
-Whether or not the navigation will result in the page being unloaded (i.e. not a client-side navigation) +A promise that resolves once the navigation is complete, and rejects if the navigation +fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve + +
+
+ +## NavigationEnter + +
+ +```dts +interface NavigationEnter extends NavigationBase {/*…*/} +``` + +
+ +```dts +type: 'enter'; +``` + +
+ +The type of navigation: +- `form`: The user submitted a `` +- `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring +- `link`: Navigation was triggered by a link click +- `goto`: Navigation was triggered by a `goto(...)` call or a redirect +- `popstate`: Navigation was triggered by back/forward navigation
@@ -1644,7 +1659,7 @@ Whether or not the navigation will result in the page being unloaded (i.e. not a
```dts -delta?: number; +delta?: undefined; ```
@@ -1657,13 +1672,12 @@ In case of a history back/forward navigation, the number of steps to go back/for
```dts -complete: Promise; +event?: undefined; ```
-A promise that resolves once the navigation is complete, and rejects if the navigation -fails or is aborted. In the case of a `willUnload` navigation, the promise will never resolve +Dispatched `Event` object when navigation occured by `popstate` or `link`.
@@ -1732,6 +1746,201 @@ The URL of the current page
+## NavigationExternal + +
+ +```dts +interface NavigationExternal extends NavigationBase {/*…*/} +``` + +
+ +```dts +type: Exclude; +``` + +
+ +The type of navigation: +- `form`: The user submitted a `` +- `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring +- `link`: Navigation was triggered by a link click +- `goto`: Navigation was triggered by a `goto(...)` call or a redirect +- `popstate`: Navigation was triggered by back/forward navigation + +
+
+ +
+ +```dts +delta?: undefined; +``` + +
+ +In case of a history back/forward navigation, the number of steps to go back/forward + +
+
+ +## NavigationFormSubmit + +
+ +```dts +interface NavigationFormSubmit extends NavigationBase {/*…*/} +``` + +
+ +```dts +type: 'form'; +``` + +
+ +The type of navigation: +- `form`: The user submitted a `` +- `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring +- `link`: Navigation was triggered by a link click +- `goto`: Navigation was triggered by a `goto(...)` call or a redirect +- `popstate`: Navigation was triggered by back/forward navigation + +
+
+ +
+ +```dts +event: SubmitEvent; +``` + +
+ +The `SubmitEvent` that caused the navigation + +
+
+ +
+ +```dts +delta?: undefined; +``` + +
+ +In case of a history back/forward navigation, the number of steps to go back/forward + +
+
+ +## NavigationLink + +
+ +```dts +interface NavigationLink extends NavigationBase {/*…*/} +``` + +
+ +```dts +type: 'link'; +``` + +
+ +The type of navigation: +- `form`: The user submitted a `` +- `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring +- `link`: Navigation was triggered by a link click +- `goto`: Navigation was triggered by a `goto(...)` call or a redirect +- `popstate`: Navigation was triggered by back/forward navigation + +
+
+ +
+ +```dts +event: PointerEvent; +``` + +
+ +The `PointerEvent` that caused the navigation + +
+
+ +
+ +```dts +delta?: undefined; +``` + +
+ +In case of a history back/forward navigation, the number of steps to go back/forward + +
+
+ +## NavigationPopState + +
+ +```dts +interface NavigationPopState extends NavigationBase {/*…*/} +``` + +
+ +```dts +type: 'popstate'; +``` + +
+ +The type of navigation: +- `form`: The user submitted a `` +- `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring +- `link`: Navigation was triggered by a link click +- `goto`: Navigation was triggered by a `goto(...)` call or a redirect +- `popstate`: Navigation was triggered by back/forward navigation + +
+
+ +
+ +```dts +delta: number; +``` + +
+ +In case of a history back/forward navigation, the number of steps to go back/forward + +
+
+ +
+ +```dts +event: PopStateEvent; +``` + +
+ +The `PopStateEvent` that caused the navigation + +
+
+ ## NavigationTarget Information about the target of a specific navigation. @@ -1842,38 +2051,23 @@ The argument passed to [`onNavigate`](/docs/kit/$app-navigation#onNavigate) call
```dts -interface OnNavigate extends Navigation {/*…*/} -``` - -
- -```dts -type: Exclude; -``` - -
- -The type of navigation: -- `form`: The user submitted a `` -- `link`: Navigation was triggered by a link click -- `goto`: Navigation was triggered by a `goto(...)` call or a redirect -- `popstate`: Navigation was triggered by back/forward navigation - -
-
- -
- -```dts -willUnload: false; +type OnNavigate = Navigation & { + /** + * The type of navigation: + * - `form`: The user submitted a `` + * - `link`: Navigation was triggered by a link click + * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect + * - `popstate`: Navigation was triggered by back/forward navigation + */ + type: Exclude; + /** + * Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page. + */ + willUnload: false; +}; ``` -
- -Since `onNavigate` callbacks are called immediately before a client-side navigation, they will never be called with a navigation that unloads the page. -
-
## Page