Deployaar uses better-auth with a Drizzle/PostgreSQL adapter for all authentication. It supports three sign-in methods: email and password, Google OAuth, and GitHub OAuth. All auth routes are served underDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/paramveer-cyber/Deployaar/llms.txt
Use this file to discover all available pages before exploring further.
/api/auth/* on the Express API server — the Next.js web app never handles auth itself. The trustedOrigins list is set to [NEXT_PUBLIC_WEB_URL] so that better-auth accepts cookie-setting requests that originate from the frontend domain.
Auth Routes
better-auth automatically mounts the following endpoints at startup. All routes are prefixed with/api/auth:
| Method | Path | Description |
|---|---|---|
POST | /api/auth/sign-in/email | Email and password sign-in. Returns a session cookie on success |
POST | /api/auth/sign-up/email | Email and password registration. Creates a new user and session |
GET | /api/auth/sign-in/google | Initiates the Google OAuth flow. Redirects to accounts.google.com |
GET | /api/auth/callback/google | Google OAuth callback. Verifies state, exchanges code for tokens, creates session |
GET | /api/auth/sign-in/github | Initiates the GitHub OAuth flow. Redirects to github.com/login/oauth/authorize |
GET | /api/auth/callback/github | GitHub OAuth callback. Verifies state, exchanges code for tokens, creates session |
GET | /api/auth/get-session | Returns the currently authenticated session, or null if unauthenticated |
POST | /api/auth/sign-out | Invalidates the current session and clears the session cookie |
Setting Up Google OAuth
Open Google Cloud Console
Go to console.cloud.google.com and navigate to APIs & Services → Credentials.
Create an OAuth 2.0 Client ID
Click Create Credentials → OAuth 2.0 Client ID. Choose Web application as the application type and give it a name.
Add the Authorized Redirect URI
Under Authorized redirect URIs, add:Replace
{BETTER_AUTH_URL} with your actual API public URL. For local development this is http://localhost:8000/api/auth/callback/google. For production it is https://deployaar.onrender.com/api/auth/callback/google.Setting Up GitHub OAuth
This is a GitHub OAuth App, used only for authenticating users into Deployaar. It is entirely separate from the GitHub App that Deployaar installs on repositories to read code and open pull requests. They have different credentials and serve different purposes.
Set the Homepage URL
Set Homepage URL to your web app’s public URL. For example:
https://deployaar.paramveer.xyz.Set the Authorization Callback URL
Set Authorization callback URL to:Replace
{BETTER_AUTH_URL} with your API’s public URL. For local development this is http://localhost:8000/api/auth/callback/github.Critical Environment Variables
The relevant snippet frompackages/services/auth/auth.ts shows exactly how these values are wired:
The Verification Table
Migration order reference:| Migration | Description |
|---|---|
0000_dusty_morg.sql | Initial schema: users, sessions, accounts |
0001_icy_lyja.sql | Creates the verification table (required for OAuth) |
0002_colorful_valkyrie.sql | Additional schema additions |
0003_naive_songbird.sql | Further schema additions |
0004_billing_plan_pro_max.sql | Adds the pro_max billing tier |
Session Management
Sessions are stored server-side in thesession database table and tied to a signed cookie set on the browser. The BETTER_AUTH_SECRET environment variable is the signing key for all cookies and session tokens — rotating it invalidates all active sessions immediately.
Key session behaviours:
GET /api/auth/get-session— Returns the current session object including theuserrecord. Returnsnullfor unauthenticated requests. This endpoint is used by both the tRPC context and the Next.js middleware to gate protected routes.POST /api/auth/sign-out— Deletes the session row from the database and clears the session cookie.- The
accounttable stores the OAuth access tokens for each connected provider (Google, GitHub), linked to theuserrow byuserId.
OAuth Flow Diagram
The sequence below shows the Google OAuth flow end-to-end. GitHub OAuth follows the same pattern withgithub.com as the provider.