Next.js is a very good base for SEO, but it doesn't do the work for you. The App Router gives you the tools: server rendering by default, a Metadata API, file-based sitemaps and robots files, and fast pages out of the box. You still have to use them correctly on every route.
The short answer to "is Next.js good for SEO" is yes, as long as your important content is rendered on the server, every page has unique metadata and a canonical URL, and you ship a sitemap. Most SEO problems I fix on Next.js sites come from a page that renders its content only in the browser, or from metadata that was set once in the root layout and never overridden.
This guide is written for developers and technical founders. All examples use the App Router as it works in current versions of Next.js.
Rendering: make sure Google gets real HTML
In the App Router, components are Server Components by default. That's good news: the HTML Google receives already contains your content. Problems start when a page is marked 'use client' at the top and fetches its content in a useEffect. Google can render JavaScript, but it does so later and with limits, and other crawlers and AI tools often don't render it at all.
My rules:
- Keep pages and layouts as Server Components. Push
'use client'down to the small interactive parts, like a menu toggle or a form. - Fetch content on the server, inside the Server Component or in a function it calls.
- Use static rendering for content that doesn't change per request. Marketing pages, blog posts and service pages should be generated at build time or cached.
- For content that changes, use revalidation rather than fully dynamic rendering where you can.
If you want the extreme version of this approach, I wrote about why your next website should be a static Next.js site.
A quick check: open a page, view the page source (not the inspector), and search for a sentence from your main content. If it's not there, crawlers without JavaScript won't see it either.
The Metadata API
The App Router replaces the old next/head approach with exported metadata. Static pages export a metadata object. Dynamic pages export a generateMetadata function.
// app/layout.tsx
import type { Metadata } from 'next';
export const metadata: Metadata = {
metadataBase: new URL('https://www.example.com'),
title: {
default: 'Example Co',
template: '%s | Example Co',
},
description: 'What Example Co does, in one sentence.',
};// app/blog/[slug]/page.tsx
import type { Metadata } from 'next';
import { getPost } from '@/lib/posts';
type Props = { params: Promise<{ slug: string }> };
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { slug } = await params;
const post = await getPost(slug);
return {
title: post.title,
description: post.excerpt,
alternates: { canonical: `/blog/${slug}/` },
openGraph: { type: 'article', title: post.title, description: post.excerpt },
};
}A few things worth knowing:
metadataBaselets you write relative URLs for canonicals and Open Graph images. Set it once in the root layout.- The title
templateadds your brand to child page titles automatically. - In current Next.js,
paramsis a Promise in pages andgenerateMetadata, so youawaitit. - Next.js deduplicates
fetchcalls with the same arguments, and you can wrap your own data function in React'scache, so fetching the post in bothgenerateMetadataand the page doesn't cost twice.
The most common mistake is a root layout with a generic title and description that every page inherits. Search Console then reports lots of duplicate titles. Every indexable page needs its own.
Sitemaps and robots
The App Router supports special files that generate these for you.
// app/sitemap.ts
import type { MetadataRoute } from 'next';
import { getAllPosts } from '@/lib/posts';
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const posts = await getAllPosts();
return [
{ url: 'https://www.example.com/', lastModified: new Date() },
...posts.map((p) => ({
url: `https://www.example.com/blog/${p.slug}/`,
lastModified: p.updatedAt,
})),
];
}// app/robots.ts
import type { MetadataRoute } from 'next';
export default function robots(): MetadataRoute.Robots {
return {
rules: { userAgent: '*', allow: '/', disallow: '/api/' },
sitemap: 'https://www.example.com/sitemap.xml',
};
}Only include canonical, indexable URLs in the sitemap. No redirects, no pages marked noindex, no filter or search URLs. Submit it in Google Search Console once it's live.
Open Graph images and social sharing
When someone shares your page on LinkedIn, Slack or WhatsApp, the preview card comes from Open Graph tags. It isn't a ranking factor, but a broken or missing preview makes shared links look untrustworthy, and fewer people click them.
The App Router has a file convention for this. Put an opengraph-image.png (or .jpg) file in a route folder and Next.js adds the right tags for that route and everything below it, unless a child route has its own. For pages like blog posts, you can instead create an opengraph-image.tsx file that generates the image from the post title using ImageResponse from next/og. That gives every article a branded card without anyone designing images by hand.
Check the result with each platform's link preview or debugging tool before launch. Social platforms cache previews, so fixing a bad image after people have shared the link can take a while to show.
Canonicals, trailing slashes and redirects
Duplicate URLs quietly split your ranking signals. On Next.js sites I check:
- Trailing slash. Decide with
trailingSlashinnext.configand keep internal links, canonicals and the sitemap consistent with that choice. - www vs non-www and HTTP vs HTTPS. Redirect all variants to one at the host or CDN level.
- Canonical tags via
alternates.canonicalon every page, especially pages reachable with query strings. - Old URLs. When migrating from WordPress or another platform, map every old URL to its new one with permanent redirects, either in
next.configredirects()or at the hosting layer. - Pages you don't want indexed (thank-you pages, internal tools) get
robots: { index: false }in their metadata.
Structured data
Next.js doesn't have a special API for JSON-LD. You render a script tag in the page:
export default async function Page() {
const jsonLd = {
'@context': 'https://schema.org',
'@type': 'Organization',
name: 'Example Co',
url: 'https://www.example.com/',
};
return (
<>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd).replace(/</g, '\\u003c') }}
/>
{/* page content */}
</>
);
}The replace escapes < characters, which the Next.js docs recommend to avoid injection if any value comes from user content. Use Article for posts, Product for products, LocalBusiness for location pages, and BreadcrumbList where it helps. Test with Google's Rich Results Test.
Performance and Core Web Vitals
Next.js gives you good defaults, but they're easy to undo.
- Use
next/imagewith correctsizesso phones don't download desktop-sized images. Tell Next.js to load the main hero image early, since it is usually the LCP element (preloadin Next 16,priorityin older versions). - Use
next/fontto self-host fonts and avoid layout shift from font swapping. - Load third-party scripts (chat widgets, analytics, pixels) with
next/scriptand a suitable strategy, so they don't block the main content. - Watch your client bundle. Every
'use client'component adds JavaScript that the browser has to download and run, which affects INP.
The targets to aim for are LCP within 2.5 seconds, INP under 200 milliseconds and CLS under 0.1 at the 75th percentile of real users. My explainer on Core Web Vitals covers what each means.
A launch checklist for Next.js SEO
Before going live I run through this:
- View source on key pages and confirm main content is in the HTML.
- Every page has a unique title and description.
metadataBaseset, canonicals present and absolute in the output.sitemap.xmllists only indexable canonical URLs.robots.txtallows crawling and points to the sitemap.- Old URLs redirect permanently to new ones.
- Open Graph images render when shared.
- JSON-LD validates with no errors.
- 404 page returns a real 404 status, using
notFound()where content doesn't exist. - Lighthouse and PageSpeed Insights show good mobile scores; real-user data follows after launch.
- Search Console verified and sitemap submitted.
The official reference for everything above is the Next.js documentation at nextjs.org/docs, which covers the Metadata API and the special files in detail.
The short version
For strong Next.js SEO with the App Router: render content on the server, give every page its own metadata through metadata or generateMetadata, generate a clean sitemap and robots file, settle your canonical URL format, add JSON-LD where it fits, and protect performance by keeping client JavaScript small. None of it is complicated, but all of it has to be done on every route.
If you're building a new site or need an existing Next.js project audited and fixed, my Next.js development service covers both. You can also contact me with the URL and I'll tell you what I'd fix first.