Complete reference for all Gately SDK methods, types, and interfaces.

Overview

The Gately SDK provides a comprehensive set of APIs for authentication, user management, and UI control. This reference covers all available methods, their parameters, return values, and usage examples.

Core Classes

Quick Reference

Authentication Methods

// Initialize client
const gately = new GatelyBrowserClient('project-id')

// Basic authentication
await gately.login(email, password)
await gately.signup(email, password, metadata)
await gately.logout()

// Passwordless authentication
await gately.sendMagicLink(email, options)
await gately.resetPassword(email)

// OAuth authentication
await gately.loginWithGoogle(options)
await gately.loginWithGithubSSO(options)

State Management

// Check authentication state
const isAuth = gately.isAuthenticated()
const user = gately.getUser()
const session = gately.getSession()

// Listen for changes
gately.onAuthStateChange((user, session) => {
  // Handle auth state changes
})

User Management

// Profile management
const profile = await gately.getUserProfile()
await gately.updateUserProfile(updates)
await gately.changePassword(current, new)
await gately.deleteUserAccount()

UI Control

// Show/hide elements based on auth state
gately.showElementOnAuth('dashboard', { hideIfLoggedOut: true })
gately.hideElementOnAuth('login-form', { hideIfLoggedIn: true })

Error Handling

All SDK methods throw errors that can be caught and handled:
try {
  await gately.login(email, password)
} catch (error) {
  console.error('Login failed:', error.message)
  console.error('Error code:', error.code)
  console.error('HTTP status:', error.status)
}

Common Error Codes

INVALID_CREDENTIALS
string
Wrong email/password combination
USER_NOT_FOUND
string
User doesn’t exist in the system
EMAIL_NOT_CONFIRMED
string
Email address not verified
RATE_LIMITED
string
Too many authentication attempts
NETWORK_ERROR
string
Connection or network issues

TypeScript Support

The SDK includes full TypeScript support with comprehensive type definitions:
import { 
  GatelyBrowserClient, 
  User, 
  Session, 
  AuthResponse,
  UserProfile,
  GatelyOptions 
} from 'https://cdn.usegately.com/gately-sdk.esm.min.js'

const gately = new GatelyBrowserClient('project-id')

// Type-safe operations
const user: User | null = gately.getUser()
const session: Session | null = gately.getSession()

Environment Support

The SDK works across different environments:
  • Browser: Full feature support including OAuth and UI control
  • Node.js: Server-side authentication and user management
  • Edge Runtime: Lightweight authentication for edge functions
  • React Native: Mobile authentication support

Next Steps