Documentation

Developer Guide

Complete documentation for extending and customizing your hackathon starter.

Pre-built API Routes Ready

This starter includes production-ready API routes for common hackathon needs. All routes include TypeScript types, validation, and error handling.

Health Check
GET
/api/health
Verify API availability and debug deployment
Usage Example
// Test the endpoint
fetch('/api/health')
  .then(res => res.json())
  .then(data => console.log(data))

// Response:
// {
//   "status": "ok",
//   "timestamp": "2024-01-01T00:00:00.000Z",
//   "environment": "development"
// }
Supabase CRUD
GET, POST, PUT, DELETE
/api/data
Full database operations with validation
Setup
# 1. Create Supabase project at supabase.com
# 2. Add to .env.local:
NEXT_PUBLIC_SUPABASE_URL=your-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-key
Usage Example
// Create a post
const response = await fetch('/api/data', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    title: 'Hello World',
    content: 'My first post',
    user_id: 'user-uuid'
  })
})

// Fetch all posts with pagination
const posts = await fetch('/api/data?limit=10&offset=0')
  .then(res => res.json())
Email Sending
POST
/api/email/send
Transactional emails with pre-built templates
Setup
# 1. Sign up at resend.com
# 2. Add to .env.local:
RESEND_API_KEY=re_your_key
RESEND_FROM_EMAIL=onboarding@resend.dev
Usage Example
// Send welcome email
await fetch('/api/email/send', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    to: 'user@example.com',
    subject: 'Welcome!',
    template: 'welcome',
    data: { name: 'John', url: 'https://app.com' }
  })
})

// Available templates:
// - welcome
// - notification
// - reset-password
// - custom (with your own HTML)
Creating Custom Routes
Examples of creating additional API endpoints
GET

GET /api/users

Fetch all users

// app/api/users/route.ts
export async function GET() {
  const users = await db.user.findMany()
  return Response.json(users)
}
POST

POST /api/users

Create a new user

// app/api/users/route.ts
export async function POST(request: Request) {
  const body = await request.json()
  const user = await db.user.create({ data: body })
  return Response.json(user)
}
Environment Variables
Configure your application with environment variables
# Supabase (included)
NEXT_PUBLIC_SUPABASE_URL="https://your-project.supabase.co"
NEXT_PUBLIC_SUPABASE_ANON_KEY="your-anon-key"
SUPABASE_SERVICE_ROLE_KEY="your-service-key"

# Resend Email (included)
RESEND_API_KEY="re_your_key"
RESEND_FROM_EMAIL="onboarding@resend.dev"

# Additional integrations
DATABASE_URL="postgresql://user:pass@localhost:5432/db"
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-here"
OPENAI_API_KEY="sk-..."
STRIPE_SECRET_KEY="sk_test_..."