Skip to main content
GitHub Wrapped works out of the box with zero configuration, but you can enhance its capabilities by setting environment variables. This guide covers all available configuration options.

Quick Start

Create a .env.local file in your project root:
# Optional: GitHub API authentication
GITHUB_TOKEN=ghp_your_token_here

# Optional: Redis caching (Upstash)
UPSTASH_REDIS_REST_URL=https://your-redis.upstash.io
UPSTASH_REDIS_REST_TOKEN=your_token_here

# Optional: Application URL
NEXT_PUBLIC_APP_URL=https://yourapp.com
Never commit .env.local or .env files to version control. These files should be listed in your .gitignore.

GitHub API Configuration

GITHUB_TOKEN

Type: string (optional)
Default: undefined
A GitHub personal access token for authenticating API requests. This significantly increases your API rate limits.
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Benefits:
  • Increases rate limit from 60 to 5,000 requests per hour
  • Enables access to private repositories (if needed)
  • Prevents IP-based rate limiting
How to create a token:
2

Generate new token

Click “Generate new token (classic)” and give it a descriptive name like “GitHub Wrapped API”
3

Select scopes

For public repositories only, you don’t need any scopes selected. For private repos, select:
  • repo - Full control of private repositories
4

Copy and save the token

Copy the generated token and add it to your .env.local file. You won’t be able to see it again!
The application works fine without a token for small-scale usage. Only add one if you’re hitting rate limits or need to access private repositories.

Caching Configuration

GitHub Wrapped uses a dual-layer caching system: in-memory cache by default, with optional Redis for distributed caching.

UPSTASH_REDIS_REST_URL

Type: string (optional)
Default: undefined
The REST API URL for your Upstash Redis instance.

UPSTASH_REDIS_REST_TOKEN

Type: string (optional)
Default: undefined
The authentication token for your Upstash Redis instance.
UPSTASH_REDIS_REST_URL=https://us1-intent-owl-12345.upstash.io
UPSTASH_REDIS_REST_TOKEN=AYQgASQgxxx...
When to use Redis:
  • Deploying to multiple serverless instances (Vercel, AWS Lambda)
  • Need persistent caching across server restarts
  • High-traffic deployments
Setting up Upstash Redis:
1

Create an Upstash account

Sign up at upstash.com
2

Create a Redis database

Create a new Redis database in the Upstash console. Choose a region close to your deployment.
3

Copy credentials

Copy the UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN from the database details page.
4

Add to environment variables

Add both values to your .env.local file or deployment platform’s environment settings.
Without Redis configured, GitHub Wrapped uses an in-memory cache that works perfectly fine for single-instance deployments but is lost on server restart.

Application Configuration

NEXT_PUBLIC_APP_URL

Type: string (optional)
Default: http://localhost:3000
The public URL where your application is deployed. Used for generating share links and Open Graph images.
.env.local
NEXT_PUBLIC_APP_URL=https://githubwrapped.tech
Variables prefixed with NEXT_PUBLIC_ are exposed to the browser. Don’t use this prefix for secrets!

NODE_ENV

Type: "development" | "production" | "test"
Default: Automatically set by Next.js
Controls the environment mode. In development mode, rate limit checking is relaxed to avoid blocking local development.
// lib/github.ts:3
const isDev = process.env.NODE_ENV === "development";

if (isDev) {
  // Skip rate limit pressure during local development
  return { remaining: Number.MAX_SAFE_INTEGER, ... };
}
You typically don’t need to set this manually. Next.js sets it automatically based on the command (dev vs build/start).

Authentication Configuration (Optional)

If you’ve implemented user authentication features:

GITHUB_CLIENT_ID

Type: string (optional) OAuth application client ID for GitHub authentication.

GITHUB_CLIENT_SECRET

Type: string (optional) OAuth application client secret for GitHub authentication.
.env.local
GITHUB_CLIENT_ID=Iv1.xxxxxxxxxxxx
GITHUB_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxx
These are only needed if you’re using the optional authentication features for “My Year in Code” functionality.

Platform-Specific Configuration

Vercel

Add environment variables in the Vercel dashboard:
  1. Go to your project settings
  2. Navigate to “Environment Variables”
  3. Add each variable with appropriate environments (Production, Preview, Development)

Docker

Pass environment variables when running the container:
docker run -p 3000:3000 \
  -e GITHUB_TOKEN=ghp_xxx \
  -e UPSTASH_REDIS_REST_URL=https://xxx.upstash.io \
  -e UPSTASH_REDIS_REST_TOKEN=xxx \
  github-wrapped
Or use a .env file with Docker Compose:
docker-compose.yml
version: '3.8'
services:
  app:
    build: .
    ports:
      - "3000:3000"
    env_file:
      - .env

Environment Variables Summary

VariableRequiredDefaultDescription
GITHUB_TOKENNoundefinedGitHub API token for higher rate limits
UPSTASH_REDIS_REST_URLNoundefinedUpstash Redis URL for distributed caching
UPSTASH_REDIS_REST_TOKENNoundefinedUpstash Redis authentication token
NEXT_PUBLIC_APP_URLNohttp://localhost:3000Public application URL
NODE_ENVAutodevelopmentEnvironment mode (set automatically)
GITHUB_CLIENT_IDNoundefinedOAuth client ID (for auth features)
GITHUB_CLIENT_SECRETNoundefinedOAuth client secret (for auth features)

Best Practices

  • Use different GitHub tokens for development and production
  • Rotate tokens periodically for security
  • Set up Redis for production deployments with multiple instances
  • Always set NEXT_PUBLIC_APP_URL in production for correct share URLs
  • Never commit .env files to version control
  • Use platform-specific secret management in production (Vercel Secrets, AWS Secrets Manager, etc.)

Next Steps

Build docs developers (and LLMs) love