Skip to main content

Create Your Project

1

Sign Up

Create a free account at app.usegately.com and create your first project.
2

Get Your Project ID

Navigate to Settings > General to find your Project ID. You’ll need this to initialize the SDK.
3

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.

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