Skip to main content

Getting Started

This guide will help you set up S-Auth for your family applications.

Prerequisites

  • Node.js 18+
  • A Cloudflare account (for Workers and D1)
  • A Vercel account (for Admin Dashboard and Launchpad)

Quick Start

1. Clone the Repository

git clone https://github.com/your-username/s-auth.git
cd s-auth

2. Set Up the OAuth Provider

cd oauth-provider
npm install

# Create the D1 database
wrangler d1 create s-auth-db
# Copy the database_id to wrangler.toml

# Run database migrations
wrangler d1 execute s-auth-db --local --file=src/database/migrations/0001_initial.sql
wrangler d1 execute s-auth-db --local --file=src/database/migrations/0002_indexes.sql
wrangler d1 execute s-auth-db --local --file=src/database/migrations/0003_seed_admin.sql
wrangler d1 execute s-auth-db --local --file=src/database/migrations/0004_launchpad_schema.sql

# Create local environment variables
echo "JWT_SECRET=your-local-jwt-secret" > .dev.vars
echo "SESSION_SECRET=your-local-session-secret" >> .dev.vars
echo "ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001" >> .dev.vars

# Start the development server
npm run dev

The OAuth provider will be available at http://localhost:8787.

3. Set Up the Admin Dashboard

cd ../admin-dashboard
npm install

# Create environment variables
cat > .env.local << EOF
NEXT_PUBLIC_OAUTH_PROVIDER_URL=http://localhost:8787
OAUTH_CLIENT_ID=admin_dashboard
OAUTH_CLIENT_SECRET=<from-seed-migration>
OAUTH_REDIRECT_URI=http://localhost:3000/callback
NEXTAUTH_SECRET=your-nextauth-secret
NEXTAUTH_URL=http://localhost:3000
EOF

# Start the development server
npm run dev

The Admin Dashboard will be available at http://localhost:3000.

4. Set Up the Launchpad

cd ../launchpad
npm install

# Create environment variables
cat > .env.local << EOF
NEXT_PUBLIC_OAUTH_PROVIDER_URL=http://localhost:8787
OAUTH_CLIENT_ID=launchpad
OAUTH_CLIENT_SECRET=<generate-via-admin>
OAUTH_REDIRECT_URI=http://localhost:3001/callback
NEXTAUTH_SECRET=your-nextauth-secret
NEXTAUTH_URL=http://localhost:3001
EOF

# Start the development server (on a different port)
npm run dev -- -p 3001

The Launchpad will be available at http://localhost:3001.

Default Admin Account

The seed migration creates a default admin account:

  • Email: admin@example.com
  • Password: ChangeMe123!

Important: Change this password immediately after first login.

Deployment

Deploy OAuth Provider to Cloudflare

cd oauth-provider

# Set production secrets
wrangler secret put JWT_SECRET
wrangler secret put SESSION_SECRET
wrangler secret put ALLOWED_ORIGINS

# Optional: Better Stack logging
wrangler secret put BETTER_STACK_TOKEN
wrangler secret put BETTER_STACK_HOST

# Deploy
wrangler deploy

Deploy Admin Dashboard to Vercel

cd admin-dashboard
vercel --prod

Set the following environment variables in Vercel:

  • NEXT_PUBLIC_OAUTH_PROVIDER_URL - Your OAuth provider URL
  • OAUTH_CLIENT_ID - admin_dashboard
  • OAUTH_CLIENT_SECRET - From your database
  • OAUTH_REDIRECT_URI - Your dashboard URL + /callback
  • NEXTAUTH_SECRET - A secure random string
  • NEXTAUTH_URL - Your dashboard URL

Deploy Launchpad to Vercel

cd launchpad
vercel --prod

Similar environment variables as the Admin Dashboard, but for the Launchpad client.

Next Steps