DEV Community

Sakthivel Murugan
Sakthivel Murugan

Posted on

How I Built a Hyperlocal Coupon Platform with Next.js Firebase for Small-Town India

The Problem

Small local shops in Tier-2/3 Indian cities (think Tirunelveli, Tenkasi, Dindigul) have zero digital presence. No website, no app, no way to offer digital coupons. National platforms like Nearbuy and MagicPin don't serve these towns.

I'm a developer at Blumensoft Technologies, and we built goCoupon — a hyperlocal coupon platform where local shops can create digital coupon codes, and shoppers can claim them for free.

Tech Stack

Layer Technology
Frontend *Next.js *
Database Firebase Firestore
Auth Firebase Auth
Hosting Google Cloud Run, Firebase App Hosting
Mobile App Flutter
Styling Tailwind CSS

Why Next.js 14?

1. SEO is Everything for Us

We need Google to index pages like /offers/tirunelveli and /restaurants-near-me. Next.js gives us:

  • Server-Side Rendering (SSR) — Google sees fully rendered HTML
  • Incremental Static Regeneration (ISR) — Pages rebuild every hour without redeploying
  • Dynamic metadata — Each city page gets unique title, description, and structured data
// Every city page gets unique SEO metadata
export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const city = getSEOCity(params.city);
  return {
    title: `Best Offers in ${city.name} Today | Deals & Coupons`,
    description: `Find ${city.name} offers...`,
  };
}
Enter fullscreen mode Exit fullscreen mode

2. App Router + React Server Components

Server Components let us fetch Firestore data without sending the Firebase SDK to the browser. Less JavaScript = faster pages = better Core Web Vitals.

3. Built-in Sitemap & Robots

Next.js generates sitemap.xml and robots.txt dynamically:

// sitemap.ts — auto-generates XML sitemap
export default async function sitemap() {
  const cities = await getActiveTerritories();
  return cities.map(city => ({
    url: `https://gocoupon.in/offers/${city}`,
    lastModified: new Date(),
    changeFrequency: 'daily',
  }));
}
Enter fullscreen mode Exit fullscreen mode

The SEO Strategy That Worked

We created 16 SEO landing pages targeting real search queries:

Page Target Keyword Monthly Searches
/today-offers today offers near me 25,000+
/free-coupons free coupon code 30,000+
/restaurants-near-me restaurant offers near me 15,000+
/salons-near-me salon offers near me 8,000+
/best-deals best deals today 10,000+

Each page has:

  • ✅ JSON-LD structured data (BreadcrumbList, FAQPage)
  • ✅ Unique H1 with target keyword
  • ✅ FAQ section (targets Google featured snippets)
  • ✅ Internal linking to city pages

Firebase Architecture

Firestore Structure:
├── businesses/
│   ├── {businessId}
│   │   ├── name, category, city
│   │   └── offers/ (subcollection)
│   │       └── {offerId}
│   │           ├── title, discount, validFrom, validThrough
│   │           └── couponCodes/ (subcollection)
│   │               └── {codeId} — unique per user
Enter fullscreen mode Exit fullscreen mode

Key design decision: Every coupon code is unique and non-shareable. When a user claims a coupon, we generate a unique code tied to their user ID. This prevents abuse and gives businesses real tracking.

The IST Timezone Trap 🕐

Our Cloud Run server runs on UTC. But our users are in IST (UTC+5:30). An offer expiring "today" (June 26 IST) was showing as expired at 6:30 PM IST because the server compared against UTC midnight.

Fix:

export function isExpiredIST(validThrough: string): boolean {
  const nowIST = new Date(Date.now() + 5.5 * 60 * 60 * 1000);
  const endIST = new Date(validThrough + 'T23:59:59+05:30');
  return nowIST > endIST;
}
Enter fullscreen mode Exit fullscreen mode

Results So Far

  • 🏙️ Live across 38 districts in Tamil Nadu
  • 📄 20+ indexed pages on Google (from ~5 before)
  • 🎟️ Unique coupon codes — no sharing, no abuse
  • 📱 Flutter mobile app for Android & iOS

Try It

👉 gocoupon.in — Browse offers near you

If you're building for local/hyperlocal markets, I'd love to hear your approach. Drop a comment!


I'm Sakthivel, developer at Blumensoft Technologies, Tirunelveli. We build digital products for small-town India.

Top comments (0)