Authentication

Complete guide to authentication features and implementation.

The boilerplate uses Better Auth, the boiler-plate is pre-configured with the following

  • Signup (Email / Password, Google, Discord, Github)
  • Sign-in
  • Forgot password
  • Sign out

All authentication methods saves new users in the database when they sucessfully signup or signin. You have to configure the database first.

Providers

We'll use Google Provider for this but any other one follow the same process.

Follow these steps to configure Google OAuth for your application:

  1. Go to the Google Cloud Console and create a new project

  2. Go to "APIs & Services" or click here and then go to "Credentials"

  3. Configure OAuth Consent Screen

    - Go to "APIs & Services" > "OAuth consent screen"
    - Select "External" user type
    - Fill in required app information:
        - App name
        - User support email (put yourself for now)
        - Developer contact email (put yourself for now)
  1. Create OAuth 2.0 Client ID

    • Go to "APIs & Services" > "Credentials"
    • Click "Create Credentials" > "OAuth client ID"
    • Select "Web application"
    • Add authorized JavaScript origins:
      http://localhost:3000 (for development)
      https://your-production-domain.com
    • Add authorized redirect URIs:
      http://localhost:3000/api/auth/callback/google (for development)
      https://your-production-domain.com/api/auth/callback/google
    • Click "Create"
  2. Copy credentials to your .env file:

    NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-client-id
    GOOGLE_CLIENT_SECRET=your-client-secret

On this page