Hooks
sanctum:redirect
Subscribe to redirect hook to inject custom event handling
Usage
The module can apply redirects in different situations, like onLogin or onLogout and you can subscribe
to this event to keep track of any redirect happening before it is done.
Subscribe to the sanctum:redirect hook which receives the URL of the target path of a redirect.
app/plugins/sanctum-listener.ts
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.hook('sanctum:redirect', (url) => {
console.log('Sanctum redirect hook triggered', url)
})
})
Here is what the hook looks like
interface RuntimeNuxtHooks {
/**
* Triggers when user has been redirected.
*/
'sanctum:redirect': (response: FetchResponse<any>) => HookResult
}