A modern, full-stack e-commerce application for a baseball cap store built with Next.js 15 and Cloudinary. This project demonstrates media literacy best practices for developers, showcasing how to effectively manage and transform images using Cloudinary's powerful API.
This application supports the "Cloud to Crowd" Media IQ course on Cloudinary Academy, free for all and designed for the Cloudinary Creators Program. Learn more at https://community.cloudinary.com and take the course at https://training.cloudinary.com/learn/course/devrel-c2c-next
- Product Catalog: Browse available baseball caps with detailed product pages
- Cloudinary Integration: Dynamic image optimization, transformations, and overlays
- Responsive Design: Beautiful, mobile-first UI built with Tailwind CSS
- Admin Panel: Access admin features and utilities
- Image Transformations: Automatic cropping, watermarking, and discount badges
- Server-Side Rendering: Fast, SEO-friendly pages with Next.js App Router
- Framework: Next.js 16+ (App Router)
- Language: TypeScript 5
- Styling: Tailwind CSS 4
- Image Management: Cloudinary & next-cloudinary
- Deployment: Netlify
- Runtime: React 19+
- Node.js 20+
- npm or yarn
- Cloudinary account (free tier works)
- Netlify account (for deployment)
- CodeSandbox account (if you want to try a sandbox rather than a local build)
-
Clone the repository
git clone <repository-url> cd start
-
Install dependencies
npm install
-
Set up environment variables
To run the final version of this app, create a
.env.localfile in thefinaldirectory with the following variables:NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=your_cloud_name NEXT_PUBLIC_CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET=baseball-cap-store NEXT_PUBLIC_CLOUDINARY_FOLDER_NAME=baseball-cap-store
Then, follow step 2 above.
npm run devThe application will be available at http://localhost:3000
npm run build
npm startnpm run lintfinal/
├── app/ # Next.js App Router pages
│ ├── admin/ # Admin panel pages
│ ├── products/ # Product detail pages
│ └── page.tsx # Home page
├── components/ # React components
│ ├── ProductCard.tsx # Product card component
│ └── ProductImage.tsx # Cloudinary image component
├── lib/ # Utility libraries
│ ├── cloudinary.ts # Cloudinary configuration
│ └── data/ # Data files (if needed)
├── products/ # Product data
│ └── products.json # Product catalog
├── scripts/ # Utility scripts
│ └── add-logo.ts # Logo upload script
├── types/ # TypeScript type definitions
└── logo/ # Logo assets
This project is configured for Netlify deployment with a netlify.toml file in the root directory.
- Connect your repository to Netlify
- Set environment variables in Netlify dashboard:
- Go to Site settings → Environment variables
- Add all the variables from your
.env.localfile
- Deploy: Netlify will automatically detect the configuration and deploy from the
finaldirectory
The netlify.toml configuration:
- Base directory:
final - Build command:
npm run build - Next.js plugin: Automatically enabled
Make sure to add all environment variables in the Netlify dashboard:
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAMENEXT_PUBLIC_CLOUDINARY_API_KEYCLOUDINARY_API_SECRETNEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESETNEXT_PUBLIC_CLOUDINARY_FOLDER_NAME
This project demonstrates several Cloudinary capabilities:
- Automatic Image Optimization: Format and quality optimization
- Smart Cropping: Automatic gravity-based cropping (
g_auto) - Overlays: Logo watermarking on product images
- Dynamic Transformations: Discount badges and text overlays
- Responsive Images: Automatic sizing and format selection
npm run dev- Start development server with Turbopacknpm run build- Build for production with Turbopacknpm run start- Start production servernpm run lint- Run ESLint
app/page.tsx- Home page with product listingapp/products/[id]/page.tsx- Individual product detail pagecomponents/ProductImage.tsx- Cloudinary image component with transformationslib/cloudinary.ts- Cloudinary SDK configurationnext.config.ts- Next.js configuration with file tracing for products.jsonnetlify.toml- Netlify deployment configuration
The products.json file is configured to be included in the build via next.config.ts. If you still encounter issues:
- Verify the file path in
next.config.tsmatches your file structure - Check that
outputFileTracingIncludesis correctly configured - Ensure the
productsdirectory is committed to your repository
- Verify all environment variables are set correctly
- Check that the upload preset exists in your Cloudinary dashboard
- Ensure product images are uploaded to the correct folder in Cloudinary
- Run
npm run initto upload the logo if it's missing
- Check that all environment variables are set in Netlify dashboard
- Verify the base directory in
netlify.tomlis correct (final) - Ensure Node.js version is 20+ in Netlify build settings
- Next.js Documentation
- Cloudinary Documentation
- next-cloudinary Documentation
- Tailwind CSS Documentation
This project is part of our 'Cloud to Crowd' course on media literacy for developers.
Built with ❤️ using Next.js by the Cloudinary Developer Relations Team