Skip to main content
This guide provides a comprehensive reference for all environment variables used in GitRead. These variables configure authentication, database connections, payments, and AI model access.

Overview

Environment variables are stored in .env.local for local development and configured in your deployment platform (Vercel) for production.
Never commit .env.local or any file containing secrets to version control. The .gitignore file excludes these files by default.

Quick setup

Create a .env.local file in your project root:
touch .env.local
Then add all required variables listed below.

Clerk authentication

Clerk provides secure user authentication and session management.

Required variables

NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/

Variable details

VariableDescriptionWhere to find
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYPublic key for client-side Clerk integrationClerk Dashboard → API Keys
CLERK_SECRET_KEYSecret key for server-side authenticationClerk Dashboard → API Keys (keep secure)
NEXT_PUBLIC_CLERK_SIGN_IN_URLURL path for sign-in pageSet to /sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URLURL path for sign-up pageSet to /sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URLRedirect after successful sign-inSet to / (home page)
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URLRedirect after successful sign-upSet to / (home page)
Variables prefixed with NEXT_PUBLIC_ are exposed to the browser. Never use this prefix for secrets.

Supabase database

Supabase provides the PostgreSQL database for user credits, README history, and payment tracking.

Required variables

NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGc...
SUPABASE_SERVICE_ROLE_KEY=eyJhbGc...

Variable details

VariableDescriptionWhere to find
NEXT_PUBLIC_SUPABASE_URLYour Supabase project URLSupabase Dashboard → Project Settings → API
NEXT_PUBLIC_SUPABASE_ANON_KEYAnonymous key for client-side operations (RLS protected)Supabase Dashboard → Project Settings → API
SUPABASE_SERVICE_ROLE_KEYService role key for admin operations (bypasses RLS)Supabase Dashboard → Project Settings → API (keep very secure)

Usage in code

The application uses two Supabase clients: Client-side operations (app/utils/supabase.ts:1):
import { createClient } from '@supabase/supabase-js'

const supabase = createClient(
  process.env.NEXT_PUBLIC_SUPABASE_URL!,
  process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
)
Server-side admin operations (app/api/generate/route.ts:11):
const supabaseAdmin = createClient(
  process.env.NEXT_PUBLIC_SUPABASE_URL!,
  process.env.SUPABASE_SERVICE_ROLE_KEY!
)
The SUPABASE_SERVICE_ROLE_KEY bypasses Row Level Security. Only use it in server-side API routes, never expose it to the client.

Stripe payments

Stripe handles credit purchases and payment processing.

Required variables

STRIPE_SECRET_KEY=sk_test_...
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...

Variable details

VariableDescriptionWhere to find
STRIPE_SECRET_KEYSecret key for server-side Stripe operationsStripe Dashboard → Developers → API Keys
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYPublic key for client-side Stripe integrationStripe Dashboard → Developers → API Keys

Pricing configuration

The credit pricing is configured in the checkout session API (app/api/create-checkout-session/route.ts:22):
const pricePerCredit = 1.25; // $1.25 per credit
const price = credits * pricePerCredit;
To change pricing, modify this value in the code.

OpenRouter AI

OpenRouter provides access to Google’s Gemini AI model for README generation.

Required variable

OPENROUTER_API_KEY=sk-or-v1-...

Variable details

VariableDescriptionWhere to find
OPENROUTER_API_KEYAPI key for OpenRouter accessOpenRouter Dashboard → API Keys

Model configuration

The AI model is configured in the generation API (app/api/generate/route.ts:322):
const client = new OpenAI({
  baseURL: "https://openrouter.ai/api/v1",
  apiKey: process.env.OPENROUTER_API_KEY
})

const response = await client.chat.completions.create({
  model: "google/gemini-2.5-pro-preview-03-25",
  messages: [
    { role: "system", content: "You are an expert technical writer." },
    { role: "user", content: prompt }
  ]
})

Application URL

The application URL is used for redirects and webhook endpoints.

Required variable

NEXT_PUBLIC_APP_URL=http://localhost:3000

Variable details

VariableDescriptionUsage
NEXT_PUBLIC_APP_URLBase URL of your applicationStripe redirects, webhook URLs, OAuth callbacks

Usage in Stripe

The app URL is used for payment redirects (app/api/create-checkout-session/route.ts:42):
const session = await stripe.checkout.sessions.create({
  success_url: `${process.env.NEXT_PUBLIC_APP_URL}/success?session_id={CHECKOUT_SESSION_ID}`,
  cancel_url: `${process.env.NEXT_PUBLIC_APP_URL}/`,
  // ...
})

Python ingestion API

The Python API handles GitHub repository ingestion and content extraction.

Required variable

PYTHON_API_KEY=your_secret_key_for_python_api

Variable details

VariableDescriptionUsage
PYTHON_API_KEYAuthentication key for the Python ingestion serviceSent in x-api-key header to https://gitread-api.onrender.com/ingest

Usage in code

The API key is used to authenticate requests (app/api/generate/route.ts:251):
const pythonApiUrl = "https://gitread-api.onrender.com/ingest";
const pythonApiKey = process.env.PYTHON_API_KEY!;

const response = await fetch(pythonApiUrl, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "x-api-key": pythonApiKey,
  },
  body: JSON.stringify({ repo_url: repoUrl }),
});
If you’re hosting your own ingestion service, update the pythonApiUrl in app/api/generate/route.ts.

Complete template

Here’s a complete .env.local template with all required variables:
.env.local
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/

# Supabase Database
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key

# Stripe Payments
STRIPE_SECRET_KEY=your_stripe_secret_key
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key

# OpenRouter AI
OPENROUTER_API_KEY=your_openrouter_api_key

# Application URL
NEXT_PUBLIC_APP_URL=http://localhost:3000

# Python Ingestion API
PYTHON_API_KEY=your_secret_key_for_python_api

Validation

The application validates critical environment variables at runtime. For example, the OpenRouter API key is checked in app/api/generate/route.ts:17:
const openRouterApiKey = process.env.OPENROUTER_API_KEY
console.log("🔑 OpenRouter API Key:", openRouterApiKey ? "Present" : "Missing")

if (!openRouterApiKey) {
  console.error("❌ OPENROUTER_API_KEY is not set in environment variables")
}

Security best practices

Follow these security practices to protect your application and user data.
  1. Never commit secrets: Ensure .env.local is in .gitignore
  2. Use different keys: Use separate keys for development and production
  3. Rotate keys regularly: Update API keys periodically
  4. Limit key permissions: Use least-privilege access for service accounts
  5. Monitor usage: Watch for unusual API usage patterns
  6. Use Vercel environment variables: Store production secrets in Vercel, not in code

Troubleshooting

Missing environment variables

If you see errors about missing environment variables:
  1. Check that .env.local exists in the project root
  2. Verify all required variables are set
  3. Ensure no typos in variable names
  4. Restart your development server after adding variables

Invalid credentials

  1. Verify keys are copied correctly (no extra spaces)
  2. Check that you’re using the correct environment (test vs. live)
  3. Ensure keys haven’t expired or been revoked
  4. Verify account access for each service

Variables not loading

  1. Restart the development server: npm run dev
  2. Clear Next.js cache: rm -rf .next
  3. Check for syntax errors in .env.local
  4. Ensure file is named exactly .env.local

Next steps

Build docs developers (and LLMs) love