SDK ReferenceReactHooks Reference

React Hooks Reference

Quick reference for all hooks exported from @aerostack/react.

useAuth()

Returns the full auth state and all auth methods.

import { useAuth } from '@aerostack/react'
 
const {
  // State
  user,            // User | null
  tokens,          // { accessToken, refreshToken?, expiresAt? } | null
  loading,         // boolean
  error,           // string | null
  isAuthenticated, // boolean
 
  // Methods
  signIn,                  // (email, password, turnstileToken?) => Promise
  signUp,                  // (email, password, opts?) => Promise
  signOut,                 // () => Promise
  sendOTP,                 // (identifier, type?) => Promise
  verifyOTP,               // (identifier, code, type?) => Promise
  verifyEmail,             // (token) => Promise
  resendVerificationEmail, // (email) => Promise
  requestPasswordReset,    // (email, turnstileToken?) => Promise
  resetPassword,           // (token, newPassword) => Promise
  refreshAccessToken,      // (refreshToken) => Promise<{ accessToken, ... }>
  refreshUser,             // () => Promise
  updateProfile,           // (updates) => Promise
  deleteAvatar,            // () => Promise
} = useAuth()

See React SDK — Authentication for full method signatures.


useAerostack()

Access the provider context.

import { useAerostack } from '@aerostack/react'
 
const {
  projectId,  // string — your project ID
  apiKey,     // string — your public API key
  baseUrl,    // string — API base URL
  realtime,   // RealtimeClient instance
  sdk,        // AerostackSDK instance (limited client-side API)
} = useAerostack()

The realtime object is the RealtimeClient — use it for channel subscriptions. See React SDK — Realtime for the full API.


Types

import type {
  User,
  AuthTokens,
  AuthState,
  ProfileUpdate,
} from '@aerostack/react'
TypeDescription
User{ id, email, name?, avatar_url?, emailVerified, createdAt?, customFields? }
AuthTokens{ accessToken, refreshToken?, expiresAt? }
AuthState{ user, tokens, loading, error }
ProfileUpdate{ name?, avatar_url?, avatar_image_id?, customFields? }