Skip to main content
abortNavigation is only usable inside a route middleware handler.

Type Signature

Parameters

Error | string
Optional error to be thrown by abortNavigation. Can be an Error object or a string message.

Return Value

Returns false to abort the navigation.

Examples

Basic Usage

The example below shows how you can use abortNavigation in a route middleware to prevent unauthorized route access:

Using String Error Message

You can pass the error as a string:

Using Error Object

You can pass the error as an Error object, e.g. caught by the catch-block:

See Also