Skip to main content

useAuth

Platforms:✓ Expo

Only users with push tokens can receive notifications. This hook can be used to manage the tokens of the currently signed in user.

import { useAuthActions } from '@healthblocks-io/core/auth'

function Page() {
// Use methods
const { signInWithEmailAndPassword } = useAuthActions()
// Read token data
const { id_token, refresh_token } = useAuthState()
}
export interface AuthContextType {
data: AuthState | null
error: Error | null
loading: boolean
mfa: MultiFactorState | null
}

API

import { useAuth } from '@healthblocks-io/core/auth'

Methods

setData(state)

Arguments

  • state: AuthState - Any valid AuthState

Overwrite the auth state. Not recommended.

handleAuth(state)

Arguments

  • state: AuthState & ErrorResponse - Anything that looks like an AuthState or error

Example

Returns

  • state: AuthState & ErrorResponse - Anything that looks like an AuthState or error handleAuth: (state: AuthState & ErrorResponse) => AuthState & ErrorResponse

    dismissError: () => void signInAnonymously: (options?: { sub?: string }) => void signInWithToken: (id_token: string) => void /**

    • Also known as "register" */ createUserWithEmailAndPassword: ( email: string, password: string, code?: string ) => Promise<{ success: boolean }> /**
    • Signs the user in with a random id */ signInWithEmailAndPassword: ( email: string, password: string ) => Promise<AuthState & ErrorResponse> sendPasswordResetEmail: (email: string) => Promise<{ sent: [string] }> refresh: () => void signOut: () => void