Skip to content

Commit c443de4

Browse files
committed
docs: global navigation failures
Close #1905
1 parent b480bd1 commit c443de4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/docs/guide/advanced/navigation-failures.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ if (isNavigationFailure(failure, NavigationFailureType.aborted)) {
6262
If you omit the second parameter: `isNavigationFailure(failure)`, it will only check if `failure` is a _Navigation Failure_.
6363
:::
6464

65+
## Global navigation failures
66+
67+
You can detect global navigation failures globally by using the [`router.afterEach()` navigation guard](./navigation-guards.md#global-after-hooks):
68+
69+
```ts
70+
router.afterEach((to, from, failure) => {
71+
if (failure) {
72+
sendToAnalytics(to, from failure)
73+
}
74+
})
75+
```
76+
6577
## Differentiating Navigation Failures
6678

6779
As we said at the beginning, there are different situations aborting a navigation, all of them resulting in different _Navigation Failures_. They can be differentiated using the `isNavigationFailure` and `NavigationFailureType`. There are three different types:

0 commit comments

Comments
 (0)