Modern Next.js frontend for the high-throughput CDN & Video Streaming Platform. Built with TypeScript, Tailwind CSS, and HLS.js for adaptive video streaming.
- Video Upload: Drag-and-drop interface with presigned URL uploads
- Adaptive Streaming: HLS.js video player with quality selection (1080p, 720p, 480p)
- Real-time Status: Live monitoring of video processing status
- Modern UI: Beautiful dark theme with gradient accents
- Responsive Design: Works seamlessly on desktop, tablet, and mobile
- Next.js 15: React framework with App Router
- TypeScript: Type-safe development
- Tailwind CSS: Utility-first CSS framework
- HLS.js: Adaptive bitrate streaming
- Axios: HTTP client for API calls
- Node.js 18+ or 20+
- npm or yarn
- Running CDN backend (from
../cdn)
# Install dependencies
npm install
# Start development server
npm run devThe frontend will be available at http://localhost:3000
# Build the application
npm run build
# Start production server
npm start# Build Docker image
docker build -t video-streamer-frontend .
# Run container
docker run -p 3000:3000 \
-e NEXT_PUBLIC_CDN_API_URL=http://localhost \
video-streamer-frontend# Start frontend with CDN backend network
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose downvideo-streamer/
├── app/ # Next.js App Router
│ ├── layout.tsx # Root layout with navigation
│ ├── page.tsx # Dashboard page with video library
│ ├── globals.css # Global styles and Tailwind
│ └── upload/
│ └── page.tsx # Video upload page
├── components/
│ ├── VideoPlayer.tsx # HLS.js video player component
│ └── VideoUploader.tsx # Upload component with progress
├── lib/
│ └── api.ts # CDN API client
├── types/
│ └── index.ts # TypeScript type definitions
├── public/ # Static assets
├── Dockerfile # Production Docker image
├── docker-compose.yml # Docker Compose configuration
├── next.config.ts # Next.js configuration
├── tailwind.config.ts # Tailwind CSS configuration
└── tsconfig.json # TypeScript configuration
Create a .env.local file:
# CDN Backend URL
NEXT_PUBLIC_CDN_API_URL=http://localhost
# For production, use your actual domain
# NEXT_PUBLIC_CDN_API_URL=https://cdn.yourdomain.comThe frontend connects to the following CDN backend endpoints:
POST /api/upload/initiate- Get presigned upload URLPOST /api/upload/{videoId}/complete- Mark upload completeGET /api/upload/{videoId}/status- Get video statusGET /api/videos- List all videos (optional)GET /videos/processed/{videoId}/master.m3u8- HLS video stream
- Navigate to the Upload page
- Drag and drop a video file or click to select
- Supported formats: MP4, MOV, AVI, MKV
- Maximum size: 5GB
- Click "Start Upload" and wait for completion
- Video will be automatically queued for processing
- Go to the Dashboard
- Videos with "READY" status can be played
- Click "Play Video" on any ready video
- Use the quality selector to choose resolution
- Supports adaptive bitrate switching
- Videos in "PROCESSING" state show progress bar
- Dashboard auto-refreshes every 5 seconds
- Processing typically takes 2-10 minutes depending on video length
# Install dependencies
npm install
# Start development server (with hot reload)
npm run dev
# Run linter
npm run lint
# Build for production
npm run buildEnsure the CDN backend is running:
cd ../cdn
./scripts/start.shThe backend should be accessible at http://localhost with HAProxy routing.
- Update
NEXT_PUBLIC_CDN_API_URLto production domain - Build optimized production bundle
- Set up reverse proxy (Nginx, Caddy, etc.)
- Enable HTTPS/TLS
- Configure CORS on backend if needed
- Set up CDN for static assets (optional)
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}# Build production image
docker build -t video-streamer-frontend:latest .
# Run with environment variables
docker run -d \
--name video-streamer-frontend \
-p 3000:3000 \
-e NEXT_PUBLIC_CDN_API_URL=https://cdn.yourdomain.com \
--network cdn_cdn-network \
video-streamer-frontend:latest- Drag-and-drop file selection
- File validation (type and size)
- Progress tracking during upload
- Three-step upload process:
- Get presigned URL from backend
- Upload directly to MinIO
- Trigger processing
- HLS.js adaptive streaming
- Quality level selection
- Auto quality switching
- Native HLS support for Safari
- Error handling and recovery
- Video library grid view
- Status badges (PENDING, PROCESSING, READY, FAILED)
- Processing progress bars
- Auto-refresh every 5 seconds
- Inline video player
- Chrome/Edge: Full support via HLS.js
- Firefox: Full support via HLS.js
- Safari: Native HLS support
- Mobile browsers: Full support
- Server-side rendering for fast initial load
- Optimized production builds with Next.js
- Lazy loading for video player
- Efficient HLS.js buffering
- Minimal bundle size with tree shaking
Issue: Upload returns 404 or network error
Solution:
- Verify CDN backend is running:
docker-compose psin../cdn - Check backend URL in
.env.local - Verify MinIO is accessible
Issue: Player shows network error
Solution:
- Ensure video status is "READY" (not PROCESSING or PENDING)
- Check browser console for HLS errors
- Verify Nginx CDN edge is running
- Test direct M3U8 URL:
http://localhost/videos/processed/{videoId}/master.m3u8
Issue: Video stays in PROCESSING state
Solution:
- Check processing worker logs:
docker-compose logs -f worker-1in../cdn - Verify Redis queue:
docker-compose exec redis redis-cli XLEN processing-jobs - Check if FFmpeg is working in worker container
import { cdnApi } from '@/lib/api';
const { videoId, uploadUrl } = await cdnApi.initiateUpload(
'myvideo.mp4',
104857600 // file size in bytes
);await cdnApi.uploadFile(file, uploadUrl, (progress) => {
console.log(`Upload progress: ${progress.percentage}%`);
});await cdnApi.completeUpload(videoId);This is a reference implementation for the video streaming CDN platform. Feel free to customize and extend!
MIT License
- Backend CDN Platform:
../cdn - CDN Documentation:
../cdn/README.md
Built with Next.js 15 and modern web technologies