next-super-meta
v1.0.5
Published
AI-powered SEO metadata generator for Next.js App Router.
Maintainers
Readme
🚀 next-super-meta
AI-powered SEO metadata generator for Next.js App Router
next-super-meta is a lightweight, powerful SEO utility for Next.js App Router.
It automates modern SEO:
- ✓ Title & Description
- ✓ Open Graph (OG) metadata
- ✓ Twitter Cards
- ✓ Canonical URLs
- ✓ JSON-LD Structured Data
- ✓ Multilingual
hreflang(NEW) - ✓ Global SEO Config with
initSuperMeta(NEW) - ✓ Optional AI-powered metadata creation
Perfect for blogs, e-commerce stores, SaaS products, and multilingual applications.
📦 Installation
npm install next-super-meta⚙️ NEW — Global Config (initSuperMeta)
You can now set global defaults once in your app/layout.tsx:
// app/layout.tsx
import { initSuperMeta } from "next-super-meta";
initSuperMeta({
siteUrl: "https://your-site.com",
defaultLang: "en-IN",
defaultType: "website",
defaultImage: "https://your-site.com/default-og.png",
});This reduces repetition and ensures consistent SEO across your app.
🌍 NEW — Multilingual SEO (hreflang Support)
You can now add language alternates:
return superMeta({
title: "Home",
description: "Welcome to our site",
url: "/",
lang: "en-IN",
languages: {
"en-IN": "/",
"hi-IN": "/hi",
}
});This generates:
{
"alternates": {
"canonical": "https://your-site.com/",
"languages": {
"en-IN": "https://your-site.com/",
"hi-IN": "https://your-site.com/hi"
}
}
}Google uses this to improve multilingual ranking.
⚡ Basic Usage
import { superMeta } from "next-super-meta";
export async function generateMetadata() {
return superMeta({
title: "About Us",
description: "Learn more about our company",
url: "/about",
});
}🧵 Dynamic Route Example (/blog/[slug])
import { superMeta } from "next-super-meta";
import { getPostBySlug } from "@/lib/db";
export async function generateMetadata({ params }) {
const post = await getPostBySlug(params.slug);
return superMeta({
title: post.title,
description: post.excerpt,
url: `/blog/${params.slug}`,
image: post.coverImage,
type: "article",
content: post.content,
});
}🤖 AI Metadata Generation (Optional)
Automatically generate SEO title & description:
export async function generateMetadata() {
return superMeta({
url: "/ai-demo",
content: `
Next.js 14 introduces Partial Prerendering for better performance...
`,
ai: true,
});
}Optional AI Environment Variables
NEXT_SUPERMETA_AI_KEY=your-openai-or-mistral-key
NEXT_SUPERMETA_AI_ENDPOINT=https://api.openai.com/v1/chat/completions
NEXT_SUPERMETA_MODEL=gpt-4o-miniIf no key is provided → AI is skipped safely.
🛍️ E-Commerce Product Example
export async function generateMetadata({ params }) {
const product = await getProduct(params.id);
return superMeta({
title: product.name,
description: product.shortDescription,
url: `/products/${params.id}`,
image: product.images[0],
type: "product",
content: product.fullDescription,
});
}📄 Add Custom JSON-LD Schema
const base = await superMeta({
title: "FAQ",
description: "Frequently asked questions",
url: "/faq",
});
return {
...base,
other: {
...base.other,
"script:ld+json": JSON.stringify({
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
name: "Does this support App Router?",
acceptedAnswer: {
"@type": "Answer",
text: "Yes! It fully supports generateMetadata()."
}
}
]
})
}
};📁 Package Structure
src/
├── index.ts
├── superMeta.ts
├── config.ts <-- NEW
├── ai.ts
├── schema.ts
├── utils.ts
└── types.ts
dist/ (build output)🛠 API Reference
| Option | Type | Description | | ----------- | --------------------------------- | ----------------------------- | | title | string | SEO title | | description | string | Meta description | | url | string | Route URL (required) | | image | string | OG image | | type | "website" / "article" / "product" | Open Graph type | | content | string | AI training content | | lang | string | Page locale | | ai | boolean | Enable AI fallback | | languages | Record<string,string> | Multilingual alternates (NEW) |
🧪 Testing Metadata
Chrome DevTools
- Elements →
<head> - Application → Manifest
- Lighthouse → SEO
🤝 Contributing
Pull requests welcome!
- Fork the repo
- Create a new branch
- Commit your changes
- Push to GitHub
- Open a Pull Request
📜 License
MIT License⭐ Support
If you find this useful:
- ⭐ Star the GitHub repo
- 📦 Use it in your Next.js project
- 🧡 Share feedback
Enjoy automated SEO for Next.js! 🎉
