Features
Authentication
Email/password, social login, and magic links
User Management
Profiles, sessions, and account management
Page Protection
Protect content based on authentication and plans
Forms
Embed and submit forms programmatically
Authentication Methods
The SDK supports two authentication methods depending on your environment:| Environment | Method | Key Type |
|---|---|---|
| Browser/Client | Project ID | Public (safe to expose) |
| Server/Node.js | API Key | Secret (never expose) |
Quick Start
Installation
- NPM
- Yarn
- CDN
Browser Usage
For client-side applications, initialize with your API key:React Usage
Server-Side Usage (Node.js)
For server-side applications, use your secret API key:API Key Types
| Key Type | Prefix | Usage | Security |
|---|---|---|---|
| Public Key | gately_pk_ | Browser/client apps | Safe to expose |
| Secret Key | gately_sk_ | Server-side only | Never expose |
Get your API keys from Settings → API Keys in your Gately dashboard.
SDK Methods
Authentication
| Method | Description |
|---|---|
login(email, password) | Login with email and password |
signup(email, password, metadata) | Create a new account |
loginWithGoogle(options) | Login with Google OAuth |
loginWithGithub(options) | Login with GitHub OAuth |
sendMagicLink(email, options) | Send a passwordless login link |
logout() | End the current session |
Session Management
| Method | Description |
|---|---|
isAuthenticated() | Check if user is logged in |
getUser() | Get the current user |
getSession() | Get the current session |
fetchSession() | Refresh and fetch session from server |
onAuthStateChange(callback) | Listen for auth state changes |
User Profile
| Method | Description |
|---|---|
getUserProfile() | Get detailed user profile |
updateUserProfile(updates) | Update user profile |
changePassword(current, new) | Change user password |
deleteUserAccount() | Delete the user’s account |
Page Protection
| Method | Description |
|---|---|
initPageProtection(options) | Initialize automatic page protection |
checkAccess(contentId) | Check if user can access content |
TypeScript Support
The SDK is written in TypeScript and includes full type definitions:Configuration Options
Next Steps
Installation
Detailed installation instructions
Authentication
Learn about authentication methods
Page Protection
Protect your content
API Keys
Learn about API key management
