Skip to content

User Authentication with Google OAuth 2.0 uses in house simple as heck server-side first Google OAuth 2.0 to help you authenticate users via Google.

You can configure it in the src/pages/api/auth/google.js and src/pages/api/auth/callback/google.js file.
  1. Update the .env file or hosting provider’s environment variable to have the necessary variables for Google OAuth 2.0:
# Obtained from Google APIs


# Based on your domain
  1. To simply authenticate users via Google, import the Sign-In-With-Google component in each framework as described below:
// File: src/pages/file.astro

import SignInWithGoogle from '@/components/Sign-In-With-Google.astro'

<html lang="en">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <SignInWithGoogle />