Skip to main content

Introduction

The Horse Trust frontend is a modern web application built with Next.js 16, utilizing the App Router architecture for optimal performance and developer experience. The platform provides a premium equestrian marketplace with advanced features for buying and selling elite horses.

Tech Stack

Core Framework

  • Next.js 16.1.6 - React framework with App Router
  • React 19.2.3 - UI library
  • TypeScript 5 - Type-safe development

Styling

  • Tailwind CSS 4 - Utility-first CSS framework
  • @tailwindcss/postcss 4 - PostCSS plugin for Tailwind
  • Custom Design System - Equestrian-themed color palette

UI Components

  • Lucide React 0.575.0 - Icon library for consistent iconography

Development

Project Structure

Key Features

Server-Side Rendering (SSR)

The application leverages Next.js 16’s App Router for server-side rendering:
app/layout.tsx

Server Actions

Server Actions provide secure backend communication:
app/actions/auth.ts

Dynamic Routes

Dynamic routing for horse details:

Data Fetching

Server-side data fetching with revalidation:

Environment Configuration

Environment Variables

API Integration

The frontend communicates with the backend API using a custom apiFetch wrapper:
app/utils/apiFetch.ts

Performance Optimizations

Image Optimization

Next.js Image component for optimized loading:

Font Loading

Google Fonts loaded via CSS with display swap:

Code Splitting

Automatic code splitting through Next.js App Router with client components marked with "use client" directive.

Metadata Configuration

Development Workflow

Local Development

Type Safety

TypeScript interfaces ensure type safety across the application:
types/index.ts

Authentication Flow

  1. User submits credentials via login form
  2. Client-side form calls loginUser server action
  3. Server action communicates with backend API
  4. HTTP-only cookie is set on successful authentication
  5. User is redirected to dashboard
  6. Header component reads cookie to display user state

Deployment

The frontend is optimized for deployment on Vercel with automatic:
  • Edge runtime optimization
  • Static page generation where applicable
  • Incremental Static Regeneration (ISR)
  • Image optimization via Next.js Image component