Skip to content

Upgrade to 0.8.0

This release contains breaking changes for all providers.

Installation

bash
npm i -D @sidebase/nuxt-auth@^0.8.0
bash
pnpm i -D @sidebase/nuxt-auth^0.8.0
bash
yarn add --dev @sidebase/nuxt-auth^0.8.0

Breaking Changes

  • auth.session renamed to auth.sessionRefresh
ts
// nuxt.config.ts

export default defineNuxtConfig({
  modules: ['@sidebase/nuxt-auth'],
  auth: {
    session: { 
      enableRefreshOnWindowFocus: true, 
      enableRefreshPeriodically: 10000, 
    }, 
    sessionRefresh: { 
      enableOnWindowFocus: true, 
      enablePeriodically: 10000, 
    }, 
  }
})

RefreshHandler

In #715, we took the first step to improve the behavior and possibilities to customize the Refresh behaviour of your application. In #766 we finalized these changes and improved the previous configuration options. You can define the location of a custom RefreshHandler inside your Nuxt config under auth.sessionRefresh.refreshHandler.

To customize the session refreshing you can provide a refresh handler. A custom RefreshHandler requires an init- and a destroy-function.

  • init will be called when the nuxt application is mounted. Here you may add event listeners and initialize custom refresh behaviour. The method will receive a RefreshHandlerConfig. The type consists of enablePeriodically & enableOnWindowFocus.
  • destroy will be called when your app is unmounted. Here you may run your clean up routine e.g. to remove your event listeners.
ts
import type { RefreshHandler } from '@sidebase/nuxt-auth'

// You may also use a plain object with `satisfies RefreshHandler`, of course!
class CustomRefreshHandler implements RefreshHandler {
  init(): void {
    console.info('Use the full power of classes to customize refreshHandler!')
  }

  destroy(): void {
    console.info(
      'Hover above class properties or go to their definition '
      + 'to learn more about how to craft a refreshHandler'
    )
  }
}

export default new CustomRefreshHandler()

Changelog

Full Changelog: https://github.com/sidebase/nuxt-auth/compare/0.7.2...0.8.0

Released under the MIT License.