Quick Start
Create a.env.local file in your project root:
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.
- Increases rate limit from 60 to 5,000 requests per hour
- Enables access to private repositories (if needed)
- Prevents IP-based rate limiting
Navigate to GitHub Settings
Generate new token
Click “Generate new token (classic)” and give it a descriptive name like “GitHub Wrapped API”
Select scopes
For public repositories only, you don’t need any scopes selected. For private repos, select:
repo- Full control of private repositories
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.
- Deploying to multiple serverless instances (Vercel, AWS Lambda)
- Need persistent caching across server restarts
- High-traffic deployments
Create an Upstash account
Sign up at upstash.com
Create a Redis database
Create a new Redis database in the Upstash console. Choose a region close to your deployment.
Copy credentials
Copy the
UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN from the database details page.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
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.
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
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:- Go to your project settings
- Navigate to “Environment Variables”
- Add each variable with appropriate environments (Production, Preview, Development)
Docker
Pass environment variables when running the container:.env file with Docker Compose:
docker-compose.yml
Environment Variables Summary
| Variable | Required | Default | Description |
|---|---|---|---|
GITHUB_TOKEN | No | undefined | GitHub API token for higher rate limits |
UPSTASH_REDIS_REST_URL | No | undefined | Upstash Redis URL for distributed caching |
UPSTASH_REDIS_REST_TOKEN | No | undefined | Upstash Redis authentication token |
NEXT_PUBLIC_APP_URL | No | http://localhost:3000 | Public application URL |
NODE_ENV | Auto | development | Environment mode (set automatically) |
GITHUB_CLIENT_ID | No | undefined | OAuth client ID (for auth features) |
GITHUB_CLIENT_SECRET | No | undefined | OAuth 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_URLin production for correct share URLs - Never commit
.envfiles to version control - Use platform-specific secret management in production (Vercel Secrets, AWS Secrets Manager, etc.)
Next Steps
- Learn about GitHub API rate limits
- Configure caching for optimal performance
- Complete the setup guide for deployment