Nube Auth is configured through environment variables and SDK options.
SDK Configuration
typescript
import { NubeAuthClient } from '@nube-auth/sdk';
const nubeAuth = new NubeAuthClient({
// Required
appId: 'your-app-id',
// API URL (defaults to hosted Nube Auth)
apiUrl: 'https://api.nubeauth.com',
// Optional: Custom redirect URI
redirectUri: 'https://yourapp.com/auth/callback',
// Optional: Storage for tokens (defaults to localStorage)
storage: localStorage,
});Environment Variables
For self-hosted deployments, configure these environment variables:
Core Settings
bash
# Application
NODE_ENV=production
PORT=3001
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/nube-auth
# Redis
REDIS_URL=redis://localhost:6379Authentication
bash
# JWT secrets (generate secure random strings)
JWT_SECRET=your-jwt-secret
SESSION_SECRET=your-session-secret
# OAuth: Google
GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret
# OAuth: GitHub
GITHUB_CLIENT_ID=your-client-id
GITHUB_CLIENT_SECRET=your-client-secretSession Settings
bash
# Session duration (seconds)
SESSION_TTL=31536000 # 365 days
# Rolling session extension
SESSION_ROLLING=true
SESSION_ROLLING_TTL=86400 # 1 dayOAuth Provider Setup
Google
- Go to Google Cloud Console
- Create OAuth 2.0 credentials
- Add authorized redirect URI:
https://your-domain/auth/callback/google - Set
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET
GitHub
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set callback URL:
https://your-domain/auth/callback/github - Set
GITHUB_CLIENT_IDandGITHUB_CLIENT_SECRET
Next Steps
- OAuth Providers - Provider details
- Environment - Full environment reference
