Javascript Reference v2.0

Stop auto-refresh session (non-browser)

Stops an active auto refresh process running in the background (if any).

  • Only useful in non-browser environments such as React Native or Electron.
  • The Supabase Auth library automatically starts and stops proactively refreshing the session when a tab is focused or not.
  • On non-browser platforms, such as mobile or desktop apps built with web technologies, the library is not able to effectively determine whether the application is focused or not.
  • When your application goes in the background or out of focus, call this method to stop the proactive refreshing of the session.

import { AppState } from 'react-native'

// make sure you register this only once!
AppState.addEventListener('change', (state) => {
  if (state === 'active') {
  } else {