A modern Next.js starter project with AI chat capabilities, featuring a nostalgic 90s web aesthetic and comprehensive testing setup.
- 🎨 90s Aesthetic: Retro "Under Construction" home page with rainbow text and blinking animations
- 🤖 AI Chat: Real-time chat interface powered by OpenRouter.ai with multiple model support
- ⚡ Modern Stack: Next.js 14, React 18, TypeScript, and Tailwind CSS
- 🛡️ Error Handling: Comprehensive error boundaries and environment validation
- 🧪 Testing: Unit tests with Vitest and E2E tests with Playwright
- 🔄 CI/CD: GitHub Actions workflow for linting, testing, and building
- 📏 Code Quality: StandardJS (ts-standard) for consistent code formatting
- Node.js 18+
- pnpm (recommended) or npm
- OpenRouter.ai API key
-
Clone the repository
git clone <your-repo-url> cd nextjs-ai-chat-starter
-
Install dependencies
pnpm install
-
Set up environment variables
cp env.example .env.local
Edit
.env.localand add your OpenRouter API key:OPENROUTER_API_KEY=your_openrouter_api_key_here OPENROUTER_MODEL=gpt-4
-
Get your OpenRouter API key
- Visit OpenRouter.ai
- Create an account and generate an API key
- Choose your preferred model (GPT-4, Claude, etc.)
-
Run the development server
pnpm dev
-
Open your browser Navigate to http://localhost:3000
├── app/ # Next.js 13+ app directory
│ ├── api/chat/ # OpenRouter API proxy
│ ├── chat/ # Chat page
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Home page
├── components/ # React components
│ └── ErrorBoundary.tsx # Error boundary component
├── lib/ # Utility functions
│ └── env.ts # Environment validation
├── tests/ # Test files
│ ├── e2e/ # Playwright E2E tests
│ ├── unit/ # Vitest unit tests
│ └── setup.ts # Test setup
├── .github/workflows/ # GitHub Actions
└── ...config files
# Run unit tests
pnpm test
# Run tests in watch mode
pnpm test:ui
# Run tests once
pnpm test:run# Run E2E tests
pnpm test:e2e
# Run E2E tests with UI
pnpm test:e2e:ui
# Run E2E tests in headed mode
pnpm test:e2e:headed| Script | Description |
|---|---|
pnpm dev |
Start development server |
pnpm build |
Build for production |
pnpm start |
Start production server |
pnpm lint |
Run StandardJS linter |
pnpm lint:fix |
Fix linting issues |
pnpm test |
Run unit tests |
pnpm test:e2e |
Run E2E tests |
| Variable | Required | Description |
|---|---|---|
OPENROUTER_API_KEY |
✅ | Your OpenRouter.ai API key |
OPENROUTER_MODEL |
✅ | AI model to use (e.g., gpt-4, claude-3-sonnet) |
NEXT_PUBLIC_APP_URL |
❌ | App URL for production |
NODE_ENV |
❌ | Node environment (auto-set by Next.js) |
Update the OPENROUTER_MODEL in your .env.local:
OPENROUTER_MODEL=claude-3-sonnet # or any model from OpenRouter- Global styles:
app/globals.css - Tailwind config:
tailwind.config.js - Component styles: Use Tailwind classes
- Create a new file in the
app/directory - Export a default React component
- Add navigation links as needed
- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy!
The app can be deployed to any platform that supports Next.js:
- Netlify
- Railway
- DigitalOcean App Platform
- AWS Amplify
- Ensure
.env.localis in the project root - Check that variable names match exactly
- Restart the development server after changes
- Verify your OpenRouter API key is correct
- Check that the model name is valid
- Look at browser console for error messages
- Run
npm installto ensure dependencies are up to date - Check that environment variables are set for testing
- For E2E tests, ensure the app builds successfully
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is open source and available under the MIT License.
- Next.js - The React framework
- OpenRouter.ai - AI model access
- Vercel AI SDK - AI integration
- Tailwind CSS - Styling
- Playwright - E2E testing
- Vitest - Unit testing
Made with ❤️ and a touch of 90s nostalgia