isAuthenticated()
Use nhost.auth.isAuthenticated to check if the user is authenticated or not.
Note: nhost.auth.isAuthenticated() can return false for two reasons:
- The user is not authenticated
- 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')}