Nuxt - Laravel Sanctum
GitHubNuxt Module
0.6
0.6
  • Getting Started
    • Introduction
    • Installation
  • Usage
    • Configuration
    • Cookie Authentication
    • Token Authentication
  • Composables
    • useSanctumAuth
    • useSanctumUser
    • useSanctumClient
    • useSanctumFetch
    • useLazySanctumFetch
    • useSanctumConfig
    • useSanctumAppConfig
  • Middleware
    • sanctum:auth
    • sanctum:guest
    • Global middleware
  • Hooks
    • sanctum:error
    • sanctum:error:request
    • sanctum:redirect
    • sanctum:init
    • sanctum:refresh
    • sanctum:login
    • sanctum:logout
  • Advanced
    • Interceptors
    • Error handling
    • Logging
    • Token storage
    • Plugin dependencies
    • Breeze Nuxt template
    • Troubleshooting
Powered by GitBook
On this page
Edit on GitHub
  1. Hooks

sanctum:redirect

Subscribe to hook and react to any redirect made by the module.

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.

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
}
Previoussanctum:error:requestNextsanctum:init

Last updated 2 months ago