How I Built an AI-Powered SEO Content Engine with Next.js and OpenAI

Dev.to / 4/15/2026

💬 OpinionDeveloper Stack & InfrastructureTools & Practical UsageModels & Research

Key Points

  • The author built an AI-powered SEO content engine that automates the workflow from keyword research through article drafting, internal linking, and WordPress publishing via a single “enter keyword, click publish” flow.
  • The system is implemented with Next.js 16 (App Router), PostgreSQL/Prisma, OpenAI’s GPT-4o-mini for article generation, JWT auth, and a Stripe billing flow for SaaS delivery.
  • A key differentiator is prompt-engineering that shapes GPT output into SEO-compliant structure (H1/H2/H3), produces optimized meta descriptions, and includes examples/statistics to improve readability and relevance.
  • For internal linking, the engine semantically analyzes existing site content, inserts a limited 3–5 contextual links per new article to avoid over-optimization.
  • WordPress integration is handled through the WordPress REST API using application passwords, enabling automated formatting and publishing to the user’s site.

I run a niche review site and was spending 3-4 hours per article writing SEO content. I decided to automate the entire pipeline — from keyword research to WordPress publishing — and turned it into a SaaS product.

Here's the technical breakdown of how I built it.

The Problem

Writing SEO content manually is painfully slow:

  • Research keywords
  • Write 1500+ word articles with proper heading structure
  • Add internal links to existing content
  • Format for WordPress
  • Publish and set meta tags

I wanted to reduce this to "enter a keyword, click publish."

Architecture

User Dashboard (Next.js 16)
    |
    ├── Keyword Research (OpenAI API)
    ├── Article Generation (GPT-4o-mini)
    ├── Smart Internal Linking Engine
    └── WordPress REST API Publisher
         |
         └── User's WordPress Site

Stack:

  • Frontend: Next.js 16 with App Router + Tailwind CSS
  • Database: PostgreSQL with Prisma 6 ORM
  • AI: OpenAI GPT-4o-mini for content generation
  • Auth: JWT with httpOnly cookies
  • Billing: Stripe Checkout + Webhooks
  • Hosting: Render (auto-deploy from GitHub)

Key Implementation Details

AI Article Generation

The prompt engineering was the hardest part. Raw GPT output reads like AI wrote it. I spent weeks refining prompts to produce content that:

  • Uses natural paragraph transitions
  • Includes relevant statistics and examples
  • Follows proper SEO heading hierarchy (H1 > H2 > H3)
  • Generates meta descriptions optimized for click-through

Smart Internal Linking

This is the feature I'm most proud of. When generating a new article, the system:

  1. Fetches all existing articles for that site
  2. Identifies semantically relevant content
  3. Automatically inserts contextual internal links
  4. Limits to 3-5 links per article to avoid over-optimization

Internal linking is one of the highest-impact SEO tactics that most people skip because it's tedious to do manually.

WordPress Integration

Publishing uses the WordPress REST API with application passwords:

const response = await fetch(`${site.wpUrl}/wp-json/wp/v2/posts`, {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${Buffer.from(`${user}:${appPassword}`).toString('base64')}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    title: article.title,
    content: article.htmlContent,
    status: 'publish',
    meta: { description: article.metaDescription },
  }),
});

Stripe Integration

Used Stripe Checkout for subscriptions — it handles the entire payment UI:

const session = await stripe.checkout.sessions.create({
  mode: 'subscription',
  line_items: [{ price: priceId, quantity: 1 }],
  success_url: `${APP_URL}/dashboard?success=true`,
  cancel_url: `${APP_URL}/dashboard`,
});

Webhook handles subscription lifecycle (created, canceled, renewed).

Results

I've been using this on my own site (topstacktools.com) for the past week:

  • 20 articles published
  • Google has already indexed the site
  • Average article generation time: ~45 seconds
  • Zero manual formatting needed

Try It

I launched it as a SaaS product with a free tier (3 articles/month, no credit card needed):

usetopseo.com

The code is private but I'm happy to answer technical questions in the comments.

Built with Next.js 16, Prisma 6, OpenAI, Stripe, and PostgreSQL. Deployed on Render.