Prerequisites
Before you begin, ensure you have the following installed:Node.js 18+
JavaScript runtime required for Next.js.Check version:
pnpm (recommended)
Fast, disk-efficient package manager.Install:Or use npm/yarn if preferred.
Git
Version control system.Check version:
PostgreSQL (optional)
Required only if using authentication.Can use hosted services like Supabase or Neon.
Initial Setup
Configure Environment Variables
Create a Add the following variables:
.env.local file in the project root:.env.local
Only
GITHUB_TOKEN is recommended for development. Other variables are optional.Set Up Database (if using auth)
If you’re using authentication features:Skip this step if you’re not working on auth features.
Start Development Server
Available Scripts
The project includes several npm scripts defined inpackage.json:
Development Workflow
Hot Reload
Next.js provides automatic hot reload for:- React components - Instant updates without losing state
- API routes - Automatic restart on changes
- Styles - Live CSS updates
- TypeScript - Type checking in background
File Watching
The dev server watches these directories:app/- Pages and API routescomponents/- React componentslib/- Business logictypes/- Type definitionspublic/- Static assets
TypeScript Integration
TypeScript errors appear in:- Terminal - Real-time type checking
- Browser - Overlay with error details
- IDE - Inline errors (VS Code, etc.)
Debugging Tips
Browser DevTools
React DevTools
React DevTools
Install React DevTools browser extension.Features:
- Inspect component tree
- View props and state
- Track re-renders
- Profile performance
Network Tab
Network Tab
Monitor API requests:
- Open DevTools (F12)
- Go to Network tab
- Filter by “Fetch/XHR”
- Inspect API calls to
/api/wrapped,/api/validate, etc.
- Response times
- Status codes
- Request/response payloads
- Rate limit headers
Console Logging
Console Logging
Use strategic console logs:
VS Code Debugger
VS Code Debugger
Add Then press F5 to start debugging with breakpoints.
.vscode/launch.json:Common Issues
Port 3000 already in use
Port 3000 already in use
Error:Solutions:
TypeScript errors on startup
TypeScript errors on startup
Error:Solution:
GitHub API rate limit exceeded
GitHub API rate limit exceeded
Error:Solutions:
- Add
GITHUB_TOKENto.env.local - Wait for rate limit reset (check headers)
- Use cache to avoid repeated requests
Redis connection failed
Redis connection failed
Error:Solution:The app automatically falls back to in-memory cache. This is expected in development.To use Redis in development:
- Sign up for Upstash Redis
- Create a database
- Add credentials to
.env.local
Module not found errors
Module not found errors
Error:Solution:
Testing Features Locally
Test Repository Input
- Go to http://localhost:3000
- Enter a repository (e.g.,
facebook/react) - Select year (e.g.,
2024) - Click “Generate Wrapped”
Test API Endpoints
Use curl or Postman to test API routes:Test Dark Mode
- Click the theme toggle in the navbar
- Verify all components render correctly
- Check localStorage:
localStorage.getItem('theme')
Test Mobile Responsiveness
- Open DevTools (F12)
- Click device toolbar (Ctrl+Shift+M)
- Test different screen sizes:
- Mobile: 375px (iPhone)
- Tablet: 768px (iPad)
- Desktop: 1920px
Performance Profiling
Next.js Build Analysis
React Profiler
- Install React DevTools
- Open Profiler tab
- Click “Record”
- Interact with the app
- Stop recording
- Analyze render times
Environment-Specific Configuration
Development Mode
Development mode includes:- Hot reload
- Detailed error messages
- Unminified code
- Source maps
- Rate limit bypass (in
lib/github.ts:23)
Production Mode
Production builds include:- Minified code
- Optimized images
- Static generation
- Tree shaking
- Code splitting
Next Steps
Project Structure
Learn about the codebase organization
Architecture
Understand the system design
Contributing
Start contributing to the project
API Reference
Explore API endpoints