Skip to main content

Initialization Options

Options Reference

apiKey (Required)

Your Gately API key. Use public keys (gately_pk_) for browser apps and secret keys (gately_sk_) for server-side only.
Never expose secret API keys (gately_sk_) in client-side code. Use public keys for browser applications.

apiUrl

The base URL for API requests. Only change this for self-hosted deployments.

autoRefresh

Automatically refresh the session before it expires.
When enabled, the SDK will:
  • Monitor session expiry time
  • Refresh the token 5 minutes before expiry
  • Update stored session automatically

suppressConsoleErrors

Suppress error messages in the browser console.

React Provider Configuration

CDN Configuration

Configure via data attributes:

Environment-Based Configuration

Server-Side Configuration (Node.js)

For server-side applications, use your secret API key:
Always use environment variables for secret keys. Never commit them to version control.

Session Storage

By default, sessions are stored in localStorage. The SDK also sets cookies for cross-origin compatibility:

Debugging

Enable verbose logging for debugging:
This will log:
  • API requests and responses
  • Session management events
  • Page protection checks
  • OAuth flow details
To disable: