Build Elevate

Web

Next.js 16 frontend application with authentication, database integration, and modern UI

Web Application

The Web application is a modern, responsive Next.js 16 frontend built with TypeScript, shadcn/ui, and Tailwind CSS. It integrates with the API, authentication, and database packages for a complete user experience.

Overview

  • Framework: Next.js 16 with TypeScript
  • Location: apps/web
  • UI Library: shadcn/ui with Tailwind CSS
  • Authentication: Better Auth with Google OAuth and two-factor support
  • Database: PostgreSQL via Prisma (shared db package)
  • Port: http://localhost:3000

Architecture

The Web app uses shared packages from the monorepo:

Features

Design System

  • shadcn/ui Components - High-quality, accessible React components
  • Tailwind CSS - Utility-first styling with responsive design
  • Dark Mode Support - Built-in light/dark mode using shadcn/ui themes
  • Responsive Layout - Mobile-first design that works on all screen sizes

Authentication

  • Session Management - Secure session handling with Better Auth
  • Google OAuth - Sign in with Google account
  • Two-Factor Authentication - Additional security layer for user accounts
  • Protected Routes - Middleware ensures authenticated access

SEO & Performance

  • Server-Side Rendering - SSR for better performance and SEO
  • Meta Tags - Automatic generation of Open Graph and Twitter Card tags
  • Image Optimization - Next.js Image component for responsive images
  • Static Generation - ISR (Incremental Static Regeneration) for frequently accessed pages

Project Structure

apps/web/
├── app/                  # Next.js app directory
│   ├── layout.tsx        # Root layout with providers
│   ├── page.tsx          # Home page
│   ├── (auth)/           # Authentication routes
│   │   ├── signin/
│   │   ├── signup/
│   │   └── ...
│   ├── (dashboard)/      # Protected dashboard routes
│   │   ├── page.tsx
│   │   ├── profile/
│   │   └── settings/
│   └── api/              # API route handlers
├── components/           # React components
│   ├── ui/               # shadcn/ui components
│   ├── forms/            # Form components
│   └── layout/           # Layout components
├── lib/                  # Utility functions
├── hooks/                # Custom React hooks
├── types/                # TypeScript type definitions
├── public/               # Static assets
├── .env.example          # Environment variables template
├── next.config.ts        # Next.js configuration
├── tsconfig.json         # TypeScript configuration
└── package.json          # Dependencies and scripts

Environment Variables

For detailed environment variable setup and configuration, see the Environment Variables Guide.

Copy .env.example to .env.local and fill in the required values following the configuration guide.

Setup & Installation

Follow the Getting Started Guide for complete setup instructions.

Quick summary for the web app:

# 1. Install dependencies
pnpm install

# 2. Configure environment variables
cp .env.example .env.local

# 3. Set up database
pnpm db:generate && pnpm db:migrate

# 4. Start development server
pnpm dev

Visit http://localhost:3000 to see the application.

The development server includes hot reload, so changes to your code are reflected instantly.

Key Scripts

CommandPurpose
pnpm devStart development server with hot reload
pnpm buildBuild for production
pnpm startStart production server
pnpm lintCheck code quality with ESLint
pnpm lint:fixAuto-fix ESLint issues
pnpm check-typesCheck TypeScript types
pnpm testRun Vitest test suite
pnpm test:watchRun tests in watch mode
pnpm test:coverageGenerate test coverage report

See Development Workflow for more commands and options.

Key Files

FilePurpose
app/layout.tsxRoot layout with providers (auth, theme, etc.)
app/(home)/page.tsxHome page
proxy.tsNext.js proxy for authentication checks
componentsAll React components
next.config.tsNext.js configuration (images, redirects, etc.)

Pages & Routes

Public Pages

  • Home (/) - Welcome page with project overview
  • Sign In (/sign-in) - User login
  • Sign Up (/sign-up) - User registration
  • Forgot Password (/forgot-password) - Password reset flow
  • Reset Password (/reset-password) - Set new password after reset request

Protected Pages (Requires Auth)

  • Dashboard (/dashboard) - User dashboard and overview
  • Profile (/profile) - User profile management
  • Settings (/settings) - Account and app settings
  • Auth Pages - Two-factor setup, session management, etc.

Development Tips

Hot Reload

Code changes automatically reload in the browser during development - no manual refresh needed.

Database Changes

After modifying schema.prisma, run:

pnpm db:generate
pnpm db:migrate

Component Development

Use the shadcn/ui component library for UI - all components are pre-configured and styled consistently.

API Integration

The app communicates with the API on http://localhost:4000 (configurable via NEXT_PUBLIC_API_URL).

Type Safety

Always use TypeScript types for database models and API responses - use @workspace/db for Prisma types.

Building for Production

# Build the application
pnpm build

# Start production server
pnpm start

# Or use Docker
docker-compose -f docker-compose.prod.yml up web

The build process:

  1. Compiles TypeScript to JavaScript
  2. Bundles dependencies
  3. Optimizes images and static assets
  4. Generates static pages where possible

Ensure all environment variables are set correctly in production before building.

Troubleshooting

Port Already in Use

See Port Already in Use in the main troubleshooting guide for platform-specific solutions.

Database Connection Errors

See Database Connection Errors in the main troubleshooting guide.

Authentication Not Working

If you can't sign in:

  1. Verify BETTER_AUTH_SECRET is set correctly
  2. Check GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET for OAuth
  3. Ensure proxy.ts is protecting routes correctly
  4. Clear browser cookies and try again

For shared authentication configuration, see Authentication Not Working in the main guide.

Build Fails

# Clear Next.js cache
rm -rf .next

# Rebuild
pnpm build

# Or check for TypeScript errors
pnpm check-types

For deployment information, see the Deployment Guide.

On this page