Nextstart uses NextAuth to authenticate users. You can configure it in the /app/api/auth/[...nextauth]/route.ts
file.
Setup
Step 1
If you haven't done it yet, add this to your .env.local
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=ybcbjukkkmcrte22c //(you can put anything here not less than 10 characters)
Step 2
Create a new project on Google Cloud
Step 3
Go to APIs & Services then Credentials
Step 4
Click [Configure Consent Screen]
Step 5
Fill info. Use the ChatGPT prompts in pages /tos & /privacy-policy to generate yours automatically. Add userinfo.email & userinfo.profile to scope. Add yourself as a test user. Submit.
Step 6
Go to Credentials and click [+ Create Credentials] then [Oauth Client ID]
Step 7
Choose [Web Application]. Add http://localhost:3000 (opens in a new tab) and https://your-site.com (opens in a new tab) to Authorized JavaScript origins. Add http://localhost:3000/api/auth/callback/google (opens in a new tab) and https://your-site.com/api/auth/callback/google (opens in a new tab) to Authorized redirect URIs (if you're using a subdomain like www, make sure to add it too). Click [Create]
Step 8
Copy paste the Client ID in GOOGLE_ID and Client Secret in GOOGLE_SECRET to .env.local.
Step 9
Go to [Oauth Consent Screen] and click [Publish App] then submit for verification. Click [Prepare for verification] and fill the missing information. Google will email you and you will have to reply to start the process. You'll need to have your domain verified with Google Search Console. You can go ahead and do that now. You can already login with Google on localhost. On production, it will work too but show a warning until you're verified (takes a few days).