SEO for Next.js Sites on Vercel
Next.js SEO comes down to six settings: the metadata API, server or static rendering, generated sitemaps and robots files, self-referencing canonicals, JSON-LD and keeping previews out of the index.
Next.js SEO comes down to a handful of framework choices: set titles, descriptions and canonicals with the metadata API, render content on the server or at build time so crawlers see it in the HTML, generate your sitemap and robots file from the same data as your pages, add JSON-LD where it describes the page honestly, and keep Vercel preview deployments out of the index.
Next.js is a good framework for SEO because it renders HTML on the server by default in the App Router. But "good by default" isn't "done." Most Next.js SEO problems I'd expect to find come from a few decisions made early: a page that fetches its content in the browser, a canonical that points at the wrong host, a sitemap that lists pages you've noindexed, or a preview URL that slipped into Google.
This is the checklist I'd run on any Next.js site deployed to Vercel. The snippets are short and generic, written for the App Router. Check the Next.js documentation for the exact API of the version you're running, since details shift between major versions. Clearing this floor is one step in a B2B SEO strategy that compounds, and it's the technical base of the SEO and AI search playbook.
Key takeaways
- Render content in the HTML. Server components and static generation give crawlers your content without waiting on browser JavaScript.
- Use the metadata API. Set a title template, metadataBase and a self-referencing canonical once, then generate per-page metadata from your content.
- Generate sitemap and robots from data. Build both from the same source as your pages so noindexed pages never appear in the sitemap.
- Keep previews out of the index. Noindex every non-production deployment and check the response headers yourself.
Which rendering mode should you use for SEO?
For content you want indexed, render on the server or at build time. In the App Router, components are server components unless you mark them with "use client", which means their output is in the HTML the server sends.
| Mode | How content arrives | SEO fit | Use for |
|---|---|---|---|
| Static generation | Built into HTML at deploy time | Best | Blog posts, glossary, marketing pages, comparison pages |
| Static with revalidation | Built once, rebuilt on a schedule or on demand | Best | Pages whose data changes occasionally, like integration directories |
| Dynamic server rendering | Built per request on the server | Good | Pages that depend on request data |
| Client-side fetch | Shell first, content after JavaScript runs | Risky | Logged-in app screens, not marketing pages |
The risky pattern is a marketing page that's a client component fetching its main copy in a useEffect. Google can render JavaScript, but you're adding a step that can fail or lag, and other crawlers and AI tools may only read the raw HTML. Keep interactive bits like tabs and calculators as small client components inside a server-rendered page.
For dynamic routes like /blog/[slug], return every slug from generateStaticParams so pages are built at deploy time instead of on first request.
How do you test what a crawler sees?
Run curl -s https://yoursite.com/some-page | grep "a sentence from the page". If the sentence isn't in the raw HTML, a crawler that doesn't run JavaScript won't see it either. Do this for one page per template, not just the homepage, because the blog template and the comparison template can behave differently.
Then confirm with URL Inspection in Search Console on the same pages. The live test shows what Google rendered and which canonical it picked. If raw HTML and rendered HTML differ on the main copy, fix the template before you publish more pages on it.
How do you set titles and descriptions with the metadata API?
Set defaults once in the root layout, then generate page-level metadata from your content.
Root layout defaults
In app/layout.tsx:
import type { Metadata } from "next";
export const metadata: Metadata = {
metadataBase: new URL("https://www.example.com"),
title: { default: "Example", template: "%s | Example" },
description: "Default description for pages that don't set one.",
};
metadataBase lets you use relative URLs for canonicals and images everywhere else. The title template appends your brand to every page title so you don't hand-type it.
Per-page metadata for dynamic routes
In a dynamic route like app/blog/[slug]/page.tsx:
export async function generateMetadata(
{ params }: { params: Promise<{ slug: string }> }
): Promise<Metadata> {
const { slug } = await params;
const post = await getPost(slug);
return {
title: post.metaTitle,
description: post.metaDescription,
alternates: { canonical: `/blog/${slug}` },
robots: post.noindex ? { index: false, follow: true } : undefined,
};
}
Two habits help. Keep metaTitle and metaDescription as separate fields from the on-page H1 in your content, so you can write each for its job. And if your meta title already includes the brand, use title: { absolute: post.metaTitle } so the template doesn't add it twice. What to actually write in those fields is covered in meta titles and descriptions that get clicked.
Return a real 404 for missing pages
If someone requests /blog/a-slug-that-doesnt-exist, the page should return a 404 status, not an empty template with a 200. Call notFound() from next/navigation when getPost comes back empty, and consider export const dynamicParams = false on routes where every valid slug comes from generateStaticParams. Empty 200 pages are the soft 404s that show up as junk in Search Console.
How should canonicals work on a Vercel site?
Every indexable page should declare a canonical tag that points at itself on your production domain. The alternates.canonical field above does that, resolved against metadataBase.
Why it matters on Vercel specifically: the same deployment can be reachable at more than one address, like your custom domain and a vercel.app address. Without a canonical, search engines have to guess which one is real. With metadataBase set to your production domain, every canonical points home no matter which address served the page.
Host, slash and parameter rules
| Situation | What to set | Where |
|---|---|---|
| www and non-www both resolve | Pick one, redirect the other | Vercel project domain settings |
| Trailing slash inconsistency | One behavior site-wide | trailingSlash option in next.config |
| UTM or filter parameters | Canonical to the clean URL | alternates.canonical without the query string |
| Old URLs after a migration | Permanent redirect to the closest new page | redirects() in next.config or Vercel project config |
| Same page reachable on vercel.app | Canonical to production, noindex non-production | metadataBase plus the preview rule below |
Next.js permanent redirects return a 308 status rather than a 301. Search engines treat both as permanent, so you don't need to force a 301 unless an old system downstream insists on it.
How do you generate a sitemap and robots file?
Next.js supports app/sitemap.ts and app/robots.ts, which generate /sitemap.xml and /robots.txt from code. Build them from the same content source as your pages so they never drift.
app/sitemap.ts:
import type { MetadataRoute } from "next";
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const posts = await getAllPosts();
return posts
.filter((p) => !p.noindex)
.map((p) => ({
url: `https://www.example.com/blog/${p.slug}`,
lastModified: p.updated,
}));
}
The filter matters. A sitemap should list only indexable, canonical pages. Listing a page you've noindexed sends mixed signals. Set lastModified from the real updated date, not the build time, or every deploy tells search engines every page changed.
app/robots.ts:
import type { MetadataRoute } from "next";
export default function robots(): MetadataRoute.Robots {
return {
rules: { userAgent: "*", allow: "/" },
sitemap: "https://www.example.com/sitemap.xml",
};
}
If you have thousands of generated pages, you'll want multiple sitemaps and a closer look at crawl budget. Programmatic SEO without the spam covers rolling those pages out in stages.
Should you add an llms.txt file?
It's cheap: a route handler at app/llms.txt/route.ts can return a plain-text summary of your key pages from the same content source. But don't expect it to move anything on its own, since there's no public commitment from the major search engines to use it. Read what it is in the llms.txt glossary entry and treat it as a five-minute extra, not a strategy.
Worked example: a 3,000-page site's build and sitemap plan
Say you run a marketing site with 200 blog and glossary pages and 2,800 programmatic integration pages, so 3,000 URLs in all. Every number below is an assumption for illustration.


| Question | Assumption and math | Result |
|---|---|---|
| Build time if every page is static | 0.2 seconds per page × 3,000 pages | 600 seconds, about 10 minutes per deploy |
| Build time with a split | Prebuild 200 core pages + 500 top integrations, render the other 2,300 on first request and cache | 700 × 0.2 = 140 seconds, under 3 minutes |
| Sitemap files needed | The sitemap protocol caps a file at 50,000 URLs, and 3,000 is far under that | 1 file now; split by section when you pass about 40,000 |
| Pages to check per template after deploy | 1 blog, 1 glossary, 1 integration, 1 comparison, plus the homepage | 5 curl checks, about 5 minutes |
The call here: prebuild what earns the most traffic, render the long tail on demand with revalidation, and keep one sitemap per section once the counts grow. Split sitemaps by section rather than by number, so when Search Console reports an indexing problem on one file, you know which template caused it.
How do you keep preview deployments out of Google?
Vercel creates a preview deployment for every branch and pull request. Those URLs are great for review and terrible in search results. Treat keeping them out as your job, and verify it rather than assuming a platform default covers you.
The approach I'd use:
- Noindex every non-production deployment. Vercel sets a
VERCEL_ENVenvironment variable toproduction,previewordevelopment. Use it in your root layout metadata:
robots: process.env.VERCEL_ENV === "production"
? undefined
: { index: false, follow: false },
- Don't rely on robots.txt alone. A
Disallowstops crawling, not indexing. A blocked URL can still show up if something links to it, and a crawler that can't fetch a page never sees its noindex directive. For previews, the noindex signal is the one that keeps them out. - Protect previews. Turn on Vercel's deployment protection for previews if your plan includes it, so outsiders can't load them at all. Check Vercel's current docs for what your plan offers.
- Verify. Run
curl -sI https://your-preview-urland look for anx-robots-tagheader, then load the page and check for a robots meta tag. Do the same on production to confirm you didn't noindex the live site by accident. That last mistake is the expensive one.
How do you add structured data in Next.js?
Render JSON-LD in a script tag from the page component. Use vocabulary from schema.org and only describe what's actually on the page.
const jsonLd = {
"@context": "https://schema.org",
"@type": "Article",
headline: post.title,
datePublished: post.date,
dateModified: post.updated,
author: { "@type": "Person", name: post.author },
};
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify(jsonLd).replace(/</g, "\\u003c"),
}}
/>
The replace escapes < characters so content can't break out of the script tag. Generate the markup from the same fields that render the page, so dateModified always matches the date readers see.
A note on FAQ markup: Google stopped showing FAQ rich results in Search on May 7, 2026. Google says FAQPage markup can stay in place, it just won't produce a visible rich result. Add it if it describes the page, but don't expect a snippet from it. Which types are still worth the effort is covered in schema markup for AI search.
What about images and speed?
Use next/image for content images. It serves resized, modern formats and requires dimensions, which prevents layout shift. Write real alt text that describes the image, and mark your above-the-fold hero image for priority loading using whatever option the current next/image docs recommend.
Other quick wins:
- Load third-party scripts like chat widgets and tag managers with
next/scriptand a strategy that doesn't block your content. - Use
next/fontso fonts are self-hosted and don't shift the layout. - Check the Core Web Vitals report in Search Console by template, not page by page.
Launch-day verification, step by step
Run this on the day you point the domain at a new Next.js build, and again after any change to the root layout or environment variables.
curl -sI https://www.example.com/returns 200, with nox-robots-tag: noindexheader.- View source on the homepage and one page per template: one title, one description, one canonical pointing at the production URL, no
noindexrobots meta tag. curl -sI https://example.com/(the other host version) returns a permanent redirect to your chosen host.- Load
/sitemap.xml: every URL returns 200, none is noindexed, none redirects. - Load
/robots.txt: it allows crawling and lists the sitemap. curl -sIon a preview URL shows a noindex header or meta tag, or the preview asks for a login.- Request a made-up slug like
/blog/zzz-testand confirm a 404 status. - Submit the sitemap in Search Console and run URL Inspection live tests on three key pages.
NEXT.JS SEO LAUNCH LOG
Date: ____ Deploy ID or commit: ____
[ ] Production indexable (header + meta) [ ] Previews noindexed or protected
[ ] One host, other redirects [ ] Canonicals point at production
[ ] Sitemap clean (200, indexable, no redirects) [ ] robots.txt lists sitemap
[ ] Unknown slug returns 404 [ ] JSON-LD validates on 1 page per template
[ ] Sitemap submitted, 3 URL Inspection tests passed
Checked by: ____
Where this breaks
Next.js sites tend to fail on configuration, not content. These are the failures worth a check in every deploy.
Production ships with noindex
Symptom: impressions fall off a cliff a week or two after a deploy. Cause: the environment check reads the wrong variable, or the production project lacks it. Early check: step 1 of the launch list, run after every deploy that touches the root layout.
Main copy rendered only in the browser
Symptom: pages are indexed but rank for nothing beyond their title. Cause: a client component fetches the body text after load. Early check: the curl-and-grep test on one page per template.
The vercel.app address in search results
Symptom: a vercel.app URL shows up for a brand search. Cause: no canonical, or a canonical built from the request host instead of metadataBase. Early check: view source on a page loaded from the vercel.app address and confirm the canonical points at production.
A sitemap full of redirects and noindexed pages
Symptom: Search Console reports many sitemap URLs as excluded. Cause: the sitemap is built from a different list than the pages, or it skips the noindex filter. Early check: step 4 of the launch list, scripted, on every deploy.
Soft 404s from dynamic routes
Symptom: Search Console flags soft 404s on URLs you never created. Cause: unknown slugs render an empty template with a 200 status. Early check: step 7 of the launch list.
When is Next.js the wrong choice for a marketing site?
If nobody on the team writes code and the site is mostly marketing pages, Next.js adds a developer to every title change, redirect and new landing page. Webflow or WordPress will get you the same SEO floor with fewer handoffs. Don't migrate a healthy site just for SEO, either: a migration risks more rankings than the framework will win back.
Next.js earns its keep when the marketing site shares code or data with the product, when you're building programmatic pages from a dataset, or when a developer owns the site anyway. Then the settings above take minutes once, and they're yours to keep clean.
A pre-launch checklist for Next.js on Vercel
- Marketing pages are server components or statically generated; key copy appears in raw HTML.
metadataBase, a title template and a default description are set in the root layout.- Every page has a unique title, description and self-referencing canonical.
generateStaticParamsreturns every slug for dynamic content routes, and unknown slugs return 404.sitemap.tslists only indexable pages;robots.tspoints to the sitemap.- Non-production deployments are noindexed and, where possible, protected.
- Production is verified as indexable with
curl -sIand a view-source check. - JSON-LD renders from page data and validates.
- Images use
next/imagewith real alt text. - One host version (www or not, slash or not) with redirects for the rest.
Run the broader one-day technical SEO audit after launch to catch what this list doesn't. Most of these settings take minutes once. Skipping them costs you in search results for as long as nobody checks.
Sources and further reading
The studies and platform docs this guide relies on, from the publishers themselves. Everything else is our own work, with the math shown above.
- Metadata and OG images, Next.js docs
- generateMetadata, Next.js docs
- Intro to how structured data markup works, Google Search Central
- Web Vitals, web.dev
- The /llms.txt file, llmstxt.org
FAQ
Is Next.js better for SEO than Webflow or WordPress?
None of them is better for SEO by itself. Next.js gives developers full control over rendering, metadata and URLs, which is great if you have someone to maintain it. Webflow and WordPress give marketers more control without a developer. Pick the one your team can actually keep clean.
Does the Pages Router work for SEO too?
Yes. The Pages Router uses different APIs, like next/head for metadata and data-fetching functions for server rendering, but the principles are the same: content in the HTML, one canonical per page, a clean sitemap. If you're starting fresh, the App Router's metadata API is simpler to keep consistent.
Do I need a separate SEO plugin or package for Next.js?
Usually not. The built-in metadata API, sitemap.ts, robots.ts and a JSON-LD script tag cover most needs. A package can help if you have unusual requirements, but more dependencies means more to update.
How do I check what Google sees on my Next.js page?
Use the URL Inspection tool in Google Search Console and run a live test. It shows the rendered HTML, the canonical Google selected and whether the page is indexable. Compare that with what your browser shows to catch content that only appears after client-side JavaScript runs.
How should redirects work when migrating an old site to Next.js?
Map every old URL that has traffic or backlinks to its closest new URL before launch, and add permanent redirects for each, either in next.config or in your Vercel project config. Avoid sending everything to the homepage, which search engines tend to treat like a missing page. Keep the redirects in place long term, since old links keep arriving for years.
Should the blog live on a subdomain or a subfolder?
I'd put it in a subfolder like /blog on the main domain, so links to posts build up one site instead of two. If the blog runs on a different system, Next.js rewrites can serve it under the main domain's path. Test canonicals and sitemaps carefully if you do, because two systems now share one host.
How do I add hreflang for multiple languages in Next.js?
The metadata API accepts language alternates alongside the canonical, so each page can list its versions in other languages. Every language version should list all the others and itself, and each should canonicalize to its own URL, not the English one. Check the current Next.js docs for the exact field shape in your version.
Does Next.js generate social share images?
The App Router supports an opengraph-image file convention, so a route can generate its own share image from the page's title. That's handy for a blog with hundreds of posts. Keep the image simple and readable at small sizes, and set Open Graph titles and descriptions in metadata too.