Package Exports
- @coldbydefault/next-seo-lite
Readme
next-seo-lite
Stop writing 50 lines of Meta tags. Do it in 5.
A tiny, zero-runtime-dependency SEO helper for Next.js App Router.
It turns simple props into the full Metadata object Next.js expects — including openGraph, twitter, and automatic canonical URLs.
Features
- Title suffixing —
"Home"becomes"Home | MyBrand"automatically. - Configurable separator — use
" – "or" · "instead of the default"|"viatitleSeparator. - OpenGraph — fills
og:title,og:description,og:image, andog:localein one call. - Twitter Cards — automatically uses
summary_large_imagewhen an image is provided, falls back tosummaryotherwise. - Canonical URLs — combine a
baseUrlwith a pagepathand you're done. - Default fallback image — set once at the root, used everywhere you don't override it.
noIndexsupport — mark private pages (/dashboard,/checkout) with a single flag.- Zero runtime dependencies — only
nextas a peer dep (for types).
Installation
This package is published to both npm and GitHub Packages — use whichever fits your workflow.
Option A — npm (recommended, zero friction)
npm install @coldbydefault/next-seo-lite
# or
yarn add @coldbydefault/next-seo-lite
# or
pnpm add @coldbydefault/next-seo-liteNo auth, no .npmrc changes needed. ✅
Option B — GitHub Packages
Useful if you're already inside a GitHub org/Actions workflow.
1. Add to your project's .npmrc:
@coldbydefault:registry=https://npm.pkg.github.com2. Authenticate once with a GitHub Personal Access Token that has read:packages scope:
npm login --registry=https://npm.pkg.github.com --scope=@coldbydefault3. Install (same command as npm):
npm install @coldbydefault/next-seo-liteQuick Start
1. One-liner per page (standalone)
// app/about/page.tsx
import { defineSEO } from "@coldbydefault/next-seo-lite";
import type { Metadata } from "next";
export const metadata: Metadata = defineSEO({
title: "About Us",
description: "Learn more about our team.",
siteName: "MyBrand",
image: "https://mysite.com/about-og.png",
baseUrl: "https://mysite.com",
path: "/about",
});That one call replaces this:
export const metadata: Metadata = {
title: "About Us | MyBrand",
description: "Learn more about our team.",
openGraph: {
title: "About Us | MyBrand",
description: "Learn more about our team.",
images: [{ url: "https://mysite.com/about-og.png" }],
type: "website",
siteName: "MyBrand",
url: "https://mysite.com/about",
},
twitter: {
card: "summary_large_image",
title: "About Us | MyBrand",
description: "Learn more about our team.",
images: ["https://mysite.com/about-og.png"],
},
alternates: {
canonical: "https://mysite.com/about",
},
};2. Global defaults with createSEOConfig (recommended)
Define your globals once, then call the returned function on every page.
// lib/seo.ts
import { createSEOConfig } from "@coldbydefault/next-seo-lite";
export const defineSEO = createSEOConfig({
siteName: "MyBrand",
baseUrl: "https://mysite.com",
defaultImage: "https://mysite.com/og-default.png",
});// app/layout.tsx
import { defineSEO } from "@/lib/seo";
import type { Metadata } from "next";
export const metadata: Metadata = defineSEO({
title: "Home",
description: "Welcome to MyBrand.",
path: "/",
});// app/blog/[slug]/page.tsx
import { defineSEO } from "@/lib/seo";
export async function generateMetadata({
params,
}: {
params: { slug: string };
}) {
const post = await getPost(params.slug);
return defineSEO({
title: post.title,
description: post.summary,
image: post.coverImage, // overrides the global defaultImage
path: `/blog/${params.slug}`,
});
}API Reference
defineSEO(props: SEOProps): Metadata
Standalone helper — no global config needed.
createSEOConfig(config: SEOConfig): (props: SEOProps) => Metadata
Returns a defineSEO function pre-loaded with your global defaults.
Page-level props always win over the global config.
SEOConfig
| Prop | Type | Description |
|---|---|---|
siteName |
string |
Appended to every title: "Page | SiteName". |
baseUrl |
string |
Absolute base URL for canonical links, e.g. "https://example.com". |
defaultImage |
string |
Fallback OG / Twitter image URL. |
titleSeparator |
string |
Separator between title and site name. Defaults to "|". |
locale |
string |
Default og:locale, e.g. "en_US". |
SEOProps
| Prop | Type | Required | Description |
|---|---|---|---|
title |
string |
✅ | Page title (without suffix). |
description |
string |
✅ | Short page description. |
image |
string |
— | Overrides defaultImage. |
path |
string |
— | Slug appended to baseUrl for the canonical URL, e.g. "/about". |
siteName |
string |
— | Overrides global siteName. Pass "" to suppress the suffix. |
baseUrl |
string |
— | Overrides global baseUrl. |
noIndex |
boolean |
— | Sets robots: { index: false, follow: false } when true. |
locale |
string |
— | Overrides global locale for og:locale, e.g. "fr_FR". |
License
MIT