Quick reference for common tasks. Bookmark this page!
import { authClient } from "@/lib/auth-client";
const { data: session } = await authClient.useSession();
if (session) {
// User is logged in
}await authClient.signOut();import { ProtectedRoute } from "@repo/auth-ui/guards/react-router";
<ProtectedRoute>
<YourProtectedContent />
</ProtectedRoute>// apps/web/src/config/redirects.ts
export const AUTH_REDIRECTS = {
afterLogin: "/your-path",
} as const;
// packages/auth/src/config/redirects.ts (must match!)
export const AUTH_REDIRECTS = {
afterLogin: "/your-path",
} as const;// apps/web/src/config/urls.ts
export const APP_URLS = {
api: "https://your-api.com",
} as const;const { data: orgs } = await authClient.organization.list();
const hasOrg = orgs && orgs.length > 0;await authClient.organization.create({
name: "My Company",
slug: "my-company",
});const { data } = await authClient.onboarding.status();
// { shouldOnboard, currentStep, completedSteps }await authClient.onboarding.completeStep("stepId", { data });await authClient.onboarding.skipStep("stepId");VITE_FRONTEND_URL=http://localhost:5173
VITE_API_BASE_URL=http://localhost:8080DATABASE_URL=postgresql://user:pass@localhost:5432/db
BETTER_AUTH_SECRET=your-secret-32-chars-minimum
BETTER_AUTH_URL=http://localhost:8080
FRONTEND_URL=http://localhost:5173| What to Change | File to Edit |
|---|---|
| Login redirect | config/redirects.ts (both) |
| Frontend URL | apps/web/src/config/urls.ts |
| API URL | apps/web/src/config/urls.ts |
| Auth config | packages/auth/src/auth.ts |
| Database schema | packages/db/src/schema/ |
| Onboarding steps | packages/auth/src/auth.ts |
| Email templates | packages/auth/src/email/ |
# Install dependencies
bun install
# Run development
bun run dev
# Database migrations
bun run db:push
# Type checking
bun run typecheck
# Linting
bun run lint| Issue | Quick Fix |
|---|---|
| Session not found | Clear cookies, re-login |
| CORS error | Check ALLOWED_ORIGINS in .env |
| Database error | Verify DATABASE_URL |
| Auth redirect loop | Check FRONTEND_URL matches |
See Troubleshooting for more.