Documentation
Login and Permissions

Login and Admin Access

Let users sign up and sign in, then open the admin area with your own account

Your signup and login pages are already included. Add a secret, connect email, and use your own account to open the admin area. Google, GitHub, and captcha are optional.

Before you start

  • Initialize local D1 using the database guide.
  • Configure Resend using the email guide, with an inbox you can use for verification.
  • Local development runs at http://localhost:3377.

Set up login

  1. Add a random authentication secret to .dev.vars. Copy a value from the generator:

    BETTER_AUTH_SECRET=replace-with-the-generated-secret
  2. Confirm your application URL in .env:

    VITE_APP_URL=http://localhost:3377
  3. Restart pnpm dev, open /login/, switch to signup, and enter your name, email, and password. Signup and login share this page.

  4. Open the verification email and follow its link. Email/password accounts must be verified before login; verification signs you in automatically.

  5. Refresh the homepage and confirm that your account menu appears.

If the login page shows 404, check that BETTER_AUTH_SECRET is filled in and the D1 setup is complete. If the verification email is missing, follow the email checks.

Set up your first administrator

Add your account email to .dev.vars:

SUPER_ADMIN_EMAIL=admin@example.com

Restart and sign in with that email, then open /admin/. If the account does not exist yet, register and verify it first. You should see the admin navigation. Separate multiple administrator emails with commas.

The admin area manages users, orders, credit packages, site settings, and AI prices. See permissions to assign roles to other administrators.

Google login (optional)

  1. Open Google Cloud Console, create a Web application OAuth client, and complete the consent screen as prompted.

  2. Add http://localhost:3377 as an authorized origin and this redirect URI:

    http://localhost:3377/api/auth/callback/google
  3. Add the credentials to .dev.vars:

    GOOGLE_CLIENT_ID=your-client-id
    GOOGLE_CLIENT_SECRET=your-client-secret
  4. Restart and complete a Google login. For production, add your real origin and https://your-domain.com/api/auth/callback/google.

GitHub login (optional)

  1. Open GitHub OAuth Apps and create an OAuth App.

  2. Use http://localhost:3377 as the local Homepage URL and this callback:

    http://localhost:3377/api/auth/callback/github
  3. Add the credentials to .dev.vars:

    GITHUB_CLIENT_ID=your-client-id
    GITHUB_CLIENT_SECRET=your-client-secret
  4. Restart and verify login. A production app uses your real domain and https://your-domain.com/api/auth/callback/github; separate OAuth Apps can serve local and production environments.

The login page already shows social login buttons. To make one work, fill in both credentials and complete a test login.

Turnstile captcha (optional)

Create a widget in Cloudflare Turnstile, add your allowed local and production domains, then configure both files:

.env: public browser settings
VITE_TURNSTILE_CAPTCHA_ENABLED=true
VITE_TURNSTILE_SITE_KEY=your-site-key
.dev.vars: server settings
TURNSTILE_CAPTCHA_ENABLED=true
TURNSTILE_SECRET_KEY=your-secret-key

Fill in both switches and both keys. Restart, then complete a signup or login with the captcha displayed.

Production and next steps

Upload authentication, email, and selected OAuth secrets to the production Worker. Set vars.VITE_APP_URL in wrangler.jsonc to your real domain; production builds read the same setting. Follow deployment for the full steps.

Once login works, configure credits or choose Stripe or Creem.

On this page