Browse documentation

beforeRoute

Observes attempts to leave the current route.

Table of contents

Category

Value

Import

js
import { beforeRoute } from "valyrian.js/router";

Public signature

ts
(callback: RouteCallback): () => void

Parameters

ts
callback: RouteCallback

Result

ts
() => void

Observable effects

Runs when leaving the current route and returns a function that unregisters the callback.

Errors

Throws RouterError when the router is not mounted or the call occurs outside a component context.