Documentation navigation
← Back to Jupiter Auth

Auth State

React to session and user changes without polling.

Subscribe

onAuthStateChange immediately emits INITIAL_SESSION after initialization, then emits later session and user events. Call unsubscribe when the listener is no longer needed.

const { data: { subscription } } =  client.auth.onAuthStateChange((event, session) => {    switch (event) {      case 'SIGNED_IN':      case 'TOKEN_REFRESHED':        console.log(session?.access_token)        break      case 'SIGNED_OUT':        console.log('Signed out')        break    }  }) subscription.unsubscribe()

Events

  • INITIAL_SESSION
  • SIGNED_IN
  • SIGNED_OUT
  • TOKEN_REFRESHED
  • PASSWORD_RECOVERY
  • USER_UPDATED
  • MFA_CHALLENGE_VERIFIED