@@ -359,6 +359,28 @@ export declare enum NavigationFailureType
359
359
| cancelled | 8 | A cancelled navigation is a navigation that failed because a more recent navigation finished started (not necessarily finished ). |
360
360
| duplicated | 16 | A duplicated navigation is a navigation that failed because it was initiated while already being at the exact same ___location . |
361
361
362
+ ## START_LOCATION
363
+
364
+ Initial route ___location where the router is . Can be used in navigation guards to differentiate the initial navigation .
365
+
366
+ ** Signature :**
367
+
368
+ ` ` ` typescript
369
+ START_LOCATION_NORMALIZED: RouteLocationNormalizedLoaded
370
+ ` ` `
371
+
372
+ ### Examples
373
+
374
+ ` ` ` js
375
+ import { START_LOCATION } from 'vue-router'
376
+
377
+ router.beforeEach((to, from) => {
378
+ if (from === START_LOCATION) {
379
+ // initial navigation
380
+ }
381
+ })
382
+ ` ` `
383
+
362
384
## Composition API
363
385
364
386
### onBeforeRouteLeave
@@ -408,3 +430,35 @@ TODO:
408
430
## TypeScript
409
431
410
432
Here are some of the interfaces and types used by Vue Router . The documentation references them to give you an idea of the existing properties in objects .
433
+
434
+ ## NavigationGuard
435
+
436
+ Navigation guard . See [Navigation Guards ](/ guide / advanced / navigation - guards .md ).
437
+
438
+ ** Signature :**
439
+
440
+ ` ` ` typescript
441
+ export interface NavigationGuard {
442
+ (
443
+ to: RouteLocationNormalized,
444
+ from: RouteLocationNormalized,
445
+ next: NavigationGuardNext
446
+ ): NavigationGuardReturn | Promise<NavigationGuardReturn>
447
+ }
448
+ ` ` `
449
+
450
+ ### Parameters
451
+
452
+ | Parameter | Type | Description |
453
+ | -------- - | ---------------------------------------------------- - | -------------------------------------------------------------------------------------------------------------------------------------------------- - |
454
+ | to | [` RouteLocationNormalized ` ](#routelocationnormalized ) | Route ___location we are navigating to |
455
+ | from | [` RouteLocationNormalized ` ](#routelocationnormalized ) | Route ___location we are navigating from |
456
+ | next | [` NavigationGuardNext ` ](#navigationguardnext ) | Callback to call to accept or reject the navigation . Can also be omitted as long as the navigation guard returns a value instead of calling ` next ` . |
457
+
458
+ ### Can return
459
+
460
+ It can return any value that can be passed to ` next ` as long as it is omitted from the list of arguments .
461
+
462
+ - ` boolean ` : Return ` true ` to accept the navigation or ` false ` to reject it .
463
+ - a [route ___location ](#routelocation ) to redirect somewhere else .
464
+ - ` undefined ` (or no ` return ` ). Same as returning ` true `
0 commit comments