Use nhost.auth.isAuthenticated to check if the user is authenticated or not.

Note: nhost.auth.isAuthenticated() can return false for two reasons:

  1. The user is not authenticated
  2. The user is not authenticated but might be authenticated soon (loading) because there is a network request in transit.

Use nhost.auth.getAuthenticationStatus to get both authentication and loading status.

const isAuthenticated = nhost.auth.isAuthenticated()

if (isAuthenticated) {
  console.log('User is authenticated')
}