Human-in-the-Loop AI Application with Google Sheets integration.
Copy .env.local.example to .env.local and fill in your values:
cp .env.local.example .env.local- G_CLIENT_ID: Google OAuth 2.0 Client ID
- G_CLIENT_SECRET: Google OAuth 2.0 Client Secret
- SHEET_ID: Google Sheet ID (from the URL)
- SHEET_API_KEY: Google Sheets API key
- NEXTAUTH_SECRET: Random secret for NextAuth.js (generate with
openssl rand -base64 32)
- SHEET_RANGE: Range in A1 notation (default:
Sheet1!A1:Z1000) - NEXTAUTH_URL: Full URL of your application (default:
http://localhost:3000)
- Go to Google Cloud Console
- Create a new project
- Enable the "Google Sheets API"
- Create OAuth 2.0 credentials (Web application)
- Add authorized redirect URI:
http://localhost:3000/api/auth/callback/google - Copy the Client ID and Client Secret to
.env.local
- Create a Google Sheet
- Enable the Sheets API in Google Cloud Console
- Create an API key
- Share the sheet with the service account (if using service account) or add the sheet ID to your OAuth credentials
- Copy the Sheet ID and API key to
.env.local
-
Push your code to GitHub/GitLab/Bitbucket
-
Go to Vercel
-
Import the project
-
Add environment variables in Settings → Environment Variables:
G_CLIENT_IDG_CLIENT_SECRETSHEET_IDSHEET_API_KEYSHEET_RANGE(optional)NEXTAUTH_URL(set to your Vercel domain, e.g.,https://velvet-echo-hitl.vercel.app)NEXTAUTH_SECRET(generate withopenssl rand -base64 32)
-
Deploy
npm install
npm run devOpen http://localhost:3000 in your browser.
The lib/sheets.js module provides functions to interact with Google Sheets:
import { getSheetData } from '@/lib/sheets'
const data = await getSheetData('Sheet1!A1:Z100')MIT