Documentation home pagelight logodark logo
  • Support
  • Dashboard
  • Dashboard
onTokenChanged()
Welcome
Getting Started
Products
Platform
Reference
Blog
  • Overview
Backend Services
  • Authentication
  • Storage
  • AI
Client Libraries
  • Javascript
    • nhost-js
    • Auth
      • HasuraAuthClient
      • changeEmail()
      • changePassword()
      • createPAT()
      • getAccessToken()
      • getAuthenticationStatus()
      • getDecodedAccessToken()
      • getHasuraClaim()
      • getHasuraClaims()
      • getSession()
      • getUser()
      • isAuthenticated()
      • isAuthenticatedAsync()
      • onAuthStateChanged()
      • onTokenChanged()
      • refreshSession()
      • resetPassword()
      • sendVerificationEmail()
      • signIn()
      • signInPAT()
      • signOut()
      • signUp()
      • addSecurityKey()
      • elevateEmailSecurityKey()
      • connectProvider()
      • signInEmailOTP()
      • verifyEmailOTP()
      • signInIdToken()
      • linkIdToken()
      • signInSecurityKey()
    • Storage
    • GraphQL
    • Functions
  • React
  • Next.js
  • Vue
  • React Native
CLI
  • Commands

onTokenChanged()

Use nhost.auth.onTokenChanged to add a custom function that runs every time the access or refresh token is changed.

nhost.auth.onTokenChanged(() =>
  console.log('The access and refresh token has changed')
)

​
Parameters


fn required OnTokenChangedFunction


Was this page helpful?

Suggest editsRaise issue
onAuthStateChanged()refreshSession()
twittergithublinkedin
Powered by Mintlify
On this page
  • Parameters