nextjs-seo

laguagu/claude-code-nextjs-skills · updated Jun 2, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/laguagu/claude-code-nextjs-skills --skill nextjs-seo
0 commentsdiscussion
summary

Complete SEO setup for Next.js 16+ apps with metadata, sitemaps, robots.txt, and Core Web Vitals guidance.

  • Covers essential files (root metadata, dynamic sitemaps, robots configuration) with ready-to-use TypeScript examples for App Router
  • Includes rendering strategy comparison (SSG, SSR, ISR, CSR) and Core Web Vitals targets (LCP, INP, CLS) for performance optimization
  • Provides quick audit checklist, common mistakes to avoid, and dynamic metadata patterns for product pages and canoni
skill.md

Next.js SEO Optimization

Comprehensive SEO guide for Next.js 16+ applications using App Router.

Next.js 16+ App Router (validated against 16.2.2 docs)

Quick SEO Audit

Run this checklist for any Next.js project:

  1. Check robots.txt: curl https://your-site.com/robots.txt
  2. Check sitemap: curl https://your-site.com/sitemap.xml
  3. Check metadata: View page source, search for <title> and <meta name="description">
  4. Check JSON-LD: View page source, search for application/ld+json
  5. Check Core Web Vitals: Run Lighthouse in Chrome DevTools

Essential Files

app/layout.tsx - Root Metadata

import type { Metadata, Viewport } from 'next';

// Viewport (separate export required in Next.js 14+)
export const viewport: Viewport = {
  width: 'device-width',
  initialScale: 1,
  maximumScale: 5,
  userScalable: true,
  themeColor: [
    { media: '(prefers-color-scheme: light)', color: '#ffffff' },
    { media: '(prefers-color-scheme: dark)', color: '#0a0a0a' },
  ],
};

export const metadata: Metadata = {
  metadataBase: new URL('https://your-site.com'),
  title: {
    default: 'Site Title - Main Keyword',
    template: '%s | Site Name',
  },
  description: 'Compelling description with keywords (150-160 chars)',
  keywords: ['keyword1', 'keyword2', 'keyword3'],
  openGraph: {
    type: 'website',
    locale: 'en_US',
    url: 'https://your-site.com',
    siteName: 'Site Name',
    title: 'Site Title',
    description: 'Description for social sharing',
    images: [{ url: '/og-image.png', width: 1200, height: 630, alt: 'Site preview' }],
  },
  twitter: {
    card: 'summary_large_image',
    title: 'Site Title',
    description: 'Description for Twitter',
    images: ['/og-image.png'],
  },
  alternates: {
    canonical: '/',
  },
  robots: {
    index: true,
    follow: true,
  },
};

app/sitemap.ts - Dynamic Sitemap

import type { MetadataRoute } from 'next';

export default function sitemap(): MetadataRoute.Sitemap {
  const baseUrl = 'https://your-site.com';

  return [
    {
      url: baseUrl,
      lastModified: new Date(),
      changeFrequency: 'weekly',
      priority: 1,
      images: [`${baseUrl}/og-image.png`], // Next.js 16 Image Sitemap
    },
    {
      url: `${baseUrl}/about`,
      lastModified: new Date(),
      changeFrequency: 'monthly',
      priority: 0.8,
    },
  ];
}

app/robots.ts - Robots Configuration

import type { MetadataRoute } from 'next';

export default function robots(): MetadataRoute.Robots {
  const baseUrl = 'https://your-site.com';

  return {
    rules: [
      {
        userAgent: '*',
        allow: '/',
        disallow: ['/api/', '/admin/'],
        // Do NOT disallow /_next/ — crawlers need render-critical CSS/JS
        // Do NOT add bot-specific rules (Googlebot, Bingbot) unless overriding wildcard
      },
    ],
    sitemap: `${baseUrl}/sitemap.xml`,
    host: baseUrl,
  };
}

Key Principles

Cache Components & SEO (Next.js 16+)

With cacheComponents: true in next.config.ts, use the "use cache" directive for SEO-critical server components:

// app/(home)/sections/hero-section.tsx
export async function HeroSection() {
  "use cache";
  cacheLife("minutes");   // Built-in profile: ~15 min
  cacheTag("hero");       // For targeted invalidation via revalidateTag("hero")

  const data = await fetchData();
  return <div>{/* SEO-visible content */}</div>;
}

Key rules:

  • "use cache" must be the first statement in the function body
  • No cookies()/headers() inside cache scope
  • Use cacheLife() + cacheTag() instead of export const revalidate
  • Sitemaps and metadata are static by default — only use "use cache" if they fetch dynamic data

Rendering Strategy for SEO

Strategy Use When SEO Impact
"use cache" Server components with periodic data Best - cached HTML, fast TTFB
SSG (Static) Content rarely changes Best - pre-rendered HTML
SSR Dynamic content per request Great - server-rendered
CSR Dashboards, authenticated areas Poor - avoid for SEO pages

Core Web Vitals Targets

Metric Target Impact
LCP (Largest Contentful Paint) < 2.5s Loading speed
INP (Interaction to Next Paint) < 200ms Interactivity
CLS (Cumulative Layout Shift) < 0.1 Visual stability

References

Common Mistakes to Avoid

  1. Mixing next-seo with Metadata API - Use only Metadata API in App Router
  2. Missing canonical URLs - Always set alternates.canonical
  3. Using CSR for SEO pages - Use SSG/SSR for indexable content
  4. Blocking /_next/ in robots.txt - Crawlers need render-critical CSS/JS; never disallow /_next/
  5. Missing metadataBase - Required for relative URLs in metadata
  6. Viewport in metadata - Must be separate export in Next.js 14+
  7. Mixing metadata object and generateMetadata - Use one or the other, not both

Quick Fixes

Add noindex to a page

export const metadata: Metadata = {
  robots: {
    index: false,
    follow: false,
how to use nextjs-seo

How to use nextjs-seo on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add nextjs-seo
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/laguagu/claude-code-nextjs-skills --skill nextjs-seo

The skills CLI fetches nextjs-seo from GitHub repository laguagu/claude-code-nextjs-skills and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/nextjs-seo

Reload or restart Cursor to activate nextjs-seo. Access the skill through slash commands (e.g., /nextjs-seo) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.733 reviews
  • Aarav Park· Dec 24, 2024

    Solid pick for teams standardizing on skills: nextjs-seo is focused, and the summary matches what you get after install.

  • Harper Jain· Dec 4, 2024

    I recommend nextjs-seo for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Daniel Martinez· Nov 23, 2024

    Useful defaults in nextjs-seo — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Charlotte Reddy· Nov 15, 2024

    Registry listing for nextjs-seo matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Kofi Abbas· Oct 14, 2024

    Registry listing for nextjs-seo matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Henry Smith· Oct 6, 2024

    Useful defaults in nextjs-seo — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Chen Johnson· Sep 25, 2024

    nextjs-seo fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Piyush G· Sep 21, 2024

    Keeps context tight: nextjs-seo is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Emma Patel· Aug 16, 2024

    nextjs-seo has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Valentina Torres· Aug 16, 2024

    Useful defaults in nextjs-seo — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

showing 1-10 of 33

1 / 4