Documentation Index Fetch the complete documentation index at: https://usegately.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Create Your Project
Get Your Project ID
Navigate to Settings > General to find your Project ID. You’ll need this to initialize the SDK.
Install the SDK
Add Gately to your website using one of the methods below.
Installation
Add this script to your HTML <head> tag: < script
src = "https://cdn.usegately.com/gately.min.js"
data-project-id = "YOUR_PROJECT_ID"
defer
></ script >
The SDK will automatically initialize and be available as window.Gately. Install the package: Initialize in your code: import { GatelyClient } from 'gately'
const gately = new GatelyClient ( 'YOUR_PROJECT_ID' )
Install the package: Wrap your app with the provider: import { GatelyProvider } from 'gately'
function App () {
return (
< GatelyProvider projectId = "YOUR_PROJECT_ID" >
< YourApp />
</ GatelyProvider >
)
}
Basic Usage
Check Authentication Status
// Check if user is logged in
if ( gately . isAuthenticated ()) {
const user = gately . getUser ()
console . log ( 'Welcome,' , user . email )
} else {
console . log ( 'Please log in' )
}
Login a User
try {
const { user , session } = await gately . login ( 'user@example.com' , 'password123' )
console . log ( 'Logged in as:' , user . email )
} catch ( error ) {
console . error ( 'Login failed:' , error . message )
}
Sign Up a New User
try {
const { user , session } = await gately . signup ( 'user@example.com' , 'SecurePass123!' , {
full_name: 'John Doe'
})
console . log ( 'Account created for:' , user . email )
} catch ( error ) {
console . error ( 'Signup failed:' , error . message )
}
Social Login
// Login with Google
await gately . loginWithGoogle ({
redirectTo: '/dashboard'
})
// Login with GitHub
await gately . loginWithGithub ({
redirectTo: '/dashboard'
})
Logout
await gately . logout ()
console . log ( 'User logged out' )
Protect Content
Add the data-gately-protected attribute to any element you want to protect:
< div data-gately-protected data-plan = "premium" >
< h2 > Premium Content </ h2 >
< p > This content is only visible to premium members. </ p >
</ div >
The SDK will automatically hide this content from non-authenticated users or users without the required plan.
Next Steps
Authentication Learn about all authentication options
SDK Reference Explore the full SDK documentation
API Reference Build custom integrations with the API
Webhooks Set up real-time event notifications