
Cosmic Intelligence
April 04, 2025

Introduction
Product Hunt has become the go-to platform for discovering new products and services in tech. In this tutorial, we'll build a simplified Product Hunt clone using Next.js 15 (App Router) with TypeScript for the frontend and Cosmic as our headless CMS. You'll learn how to implement core features like product listings, upvoting, user comments, and product collections.
What we'll be building:

Project Setup
Let's begin by creating a new Next.js project:
Choose the following options:
- TypeScript: Yes
- ESLint: Yes
- Tailwind CSS: Yes
- App Router: Yes
- Import alias: Yes (use @/ as the import alias)
Next, let's install the Cosmic SDK:
Setting Up Cosmic
First, create a new bucket in your Cosmic dashboard.
Next, we'll create a script to set up our content model and seed some initial data:
Run the seed script to set up your Cosmic bucket with both object types and demo content:
Environment Configuration
Create a file with your Cosmic credentials:
Creating Our API Service
Let's create a service to interact with the Cosmic API:
Building the UI Components
Now let's create the necessary UI components:
Header Component
ProductCard Component
Building the Pages
Homepage
Product Detail Page
Upvote Button Component
Comment Form Component
Collections Page
API Routes for Interactivity
Upvote API
Comments API
Building the Category Page
Collection Detail Page
Conclusion
In this tutorial, we've built a functional Product Hunt clone using Next.js and Cosmic. We've implemented core features like:
- Product listings with upvoting functionality
- Product detail pages with comments
- Categories and collections for product organization
- API routes for interactive features
The application demonstrates how Cosmic's headless CMS can be used to power complex web applications with rich content models and relationships between different content types.
Next Steps
To continue improving this application, you could:
- Add user authentication with NextAuth.js
- Implement product submission functionality
- Add search capabilities
- Create user profiles
- Add analytics to track product popularity
- Implement email notifications for new products or comments
The flexibility of Cosmic's content model allows you to easily extend this application with additional features as needed.
You can find more developer resources at the Cosmic documentation and explore ready-to-use templates in the Cosmic templates gallery.