Why Next.js Is the Right Foundation for SEO
Next.js is not just a React framework. It is the best production infrastructure available for SEO-critical applications. Server-side rendering, static generation, streaming, edge deployment, and image optimisation are all first-class citizens. When configured correctly, a Next.js application can hit 95+ Lighthouse scores on every route and give Google everything it needs to crawl, index, and rank your content.
This guide covers the full technical SEO stack for Next.js App Router projects.
Metadata API
The App Router's Metadata API replaces the old next/head approach with a type-safe, co-located system.
Static metadata (page-level):
// app/services/seo/page.tsx
export const metadata: Metadata = {
title: 'SEO Strategy Services',
description: 'Technical SEO and organic growth systems.',
openGraph: {
title: 'SEO Strategy Services',
description: 'Technical SEO and organic growth systems.',
type: 'website',
},
};Dynamic metadata (for blog posts, product pages):
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const post = await getPost(params.slug);
return {
title: post.title,
description: post.excerpt,
};
}Title templates prevent you from hardcoding the site name on every page:
// app/layout.tsx
export const metadata: Metadata = {
title: {
default: 'Scalentic Digital',
template: '%s | Scalentic Digital',
},
};Structured Data (Schema.org)
Structured data enables rich results in Google Search, such as FAQ accordions, article bylines, breadcrumbs and review stars. It doesn't directly improve rankings, but it dramatically improves click-through rate, which indirectly does.
The cleanest implementation in Next.js is a server component that outputs a <script type="application/ld+json"> tag:
export function SchemaOrg({ type, data }: { type: string; data: object }) {
return (
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify({ '@context': 'https://schema.org', '@type': type, ...data }),
}}
/>
);
}For FAQ pages, add the FAQPage schema with each question and answer. For articles, use Article with datePublished, author, and publisher. For the homepage, use Organization with your NAP (name, address, phone).
Sitemap Generation
Next.js App Router has built-in sitemap generation via a sitemap.ts file:
// app/sitemap.ts
export default function sitemap(): MetadataRoute.Sitemap {
return [
{ url: 'https://example.com', lastModified: new Date(), changeFrequency: 'monthly', priority: 1 },
{ url: 'https://example.com/services', lastModified: new Date(), changeFrequency: 'monthly', priority: 0.8 },
];
}For dynamic content (blog posts, case studies), fetch your slugs and map them into the sitemap array. Vercel auto-generates the sitemap URL and serves it at /sitemap.xml.
Robots.txt
// app/robots.ts
export default function robots(): MetadataRoute.Robots {
return {
rules: { userAgent: '*', allow: '/', disallow: ['/api/', '/admin/'] },
sitemap: 'https://example.com/sitemap.xml',
};
}Image Optimisation
The <Image> component is your single highest-leverage SEO tool in Next.js. It:
- Serves AVIF/WebP automatically
- Adds
widthandheightto prevent CLS - Lazy loads below-the-fold images
- Preloads above-the-fold images when you add
priority
Always set alt text on every image. Always use priority on the hero/LCP image.
Canonical URLs
Prevent duplicate content issues by setting canonical URLs explicitly on paginated content, filtered views, and any page that could be reached via multiple URLs:
export const metadata: Metadata = {
alternates: {
canonical: 'https://example.com/blog/my-post',
},
};metadataBase
Set metadataBase in your root layout so relative URLs in OG images and canonical tags resolve correctly:
export const metadata: Metadata = {
metadataBase: new URL('https://example.com'),
};Without this, Next.js will warn and relative image URLs in OG tags will be broken.
Vercel Analytics + Speed Insights
Deploy to Vercel and enable Speed Insights for real-user Core Web Vitals data. Lab data (Lighthouse) tells you what's possible; field data tells you what's actually happening for your users. Both matter, but field data is what Google uses.
Building SEO into the foundation takes a few hours. Retrofitting it onto a 50-page site takes weeks and leaves gaps. Do it at the start.