Next.js is one of the best frameworks for building websites and web apps that need to rank in search engines, but it does not make a site rank on its own. Search performance depends on how pages are rendered, how metadata is generated, how fast pages load, how the site is structured, and, above all, whether the content answers what people are searching for. This guide covers the technical side: what to configure in a Next.js App Router project so that search engines can crawl, understand, and trust every page.
It reflects the approach we use on client projects and on this website, which is built with Next.js and exported as static HTML.
Choose the right rendering mode for each page
Search engines can render JavaScript, but rendering is deferred and not guaranteed to be complete. Pages that matter for search should send their main content as HTML in the first response.
- Static generation suits marketing pages, service pages, documentation, and blog posts. Pages are built once and served from a CDN or static host, which is fast and robust. With
output: "export", the entire site becomes plain HTML files. - Incremental static regeneration suits large catalogues or content managed in a CMS that changes regularly.
- Server rendering suits pages that depend on the request, such as search results or personalised views. Keep these out of the index if they have no unique value.
- Client-only rendering is fine for dashboards behind a login, which should not be indexed anyway.
Avoid "loading shells" where the HTML contains a spinner and the content arrives later through JavaScript. If you view the page source and cannot see the main heading and text, neither can a crawler on its first pass.
Generate metadata for every page
The App Router's Metadata API lets each route export a metadata object or a generateMetadata function. Use a helper so every page gets consistent output:
- A unique title of roughly 50 to 60 characters that leads with the topic the page should rank for.
- A unique meta description of up to about 155 characters that summarises the page and gives a reason to click.
- A canonical URL, absolute and in one consistent form (choose www or non-www, and with or without a trailing slash, and stick to it).
- Open Graph and Twitter card tags with a title, description, and a 1200 by 630 image, so links look good when shared.
- robots directives where needed, for example
noindexon thin utility pages, search results, or pages that are not ready.
Set metadataBase in the root layout so relative image URLs resolve correctly, and use a title template such as "%s | Brand" so the brand appears consistently.
Canonical host and redirects
One page should be available at one URL. Redirect HTTP to HTTPS, the bare domain to www (or the reverse), old URLs to their replacements, and any secondary domains to the main one, all with permanent 301 redirects. If the same content is reachable on two domains, search engines must pick one, and the ranking signals are split. In a static export, set these redirects at the web server or hosting layer, because Next.js redirects in next.config do not apply to exported files.
Sitemaps and robots.txt
Next.js can generate both from app/sitemap.ts and app/robots.ts. In the sitemap:
- List only canonical, indexable URLs that return a 200 status.
- Use real last-modified dates from your content, not the build time. Stamping every page with today's date teaches search engines to ignore the field.
- Regenerate it on every build so new pages appear automatically.
In robots.txt, allow crawling of public pages and point to the sitemap. Do not block CSS or JavaScript that pages need to render. Remember that robots.txt prevents crawling, not indexing; use noindex for pages that must stay out of results.
Submit the sitemap in Google Search Console and Bing Webmaster Tools, and check the indexing reports regularly.
Structured data with JSON-LD
Structured data helps search engines understand what a page is about and can make it eligible for rich results. Render it as a script tag of type application/ld+json in the page component. Common types for a business website:
- Organization or LocalBusiness on the home page, with name, logo, contact details, address, and social profiles.
- Service on service pages.
- BlogPosting or Article on articles, with headline, dates, author, and image.
- BreadcrumbList on any page below the home page.
- FAQPage only where the questions and answers are visible on the page.
Only mark up content that users can see, keep the details consistent with what the page says, and validate the output with Google's Rich Results Test and the Schema.org validator. Inconsistent business details across your site, your Google Business Profile, and directories weaken trust signals, so keep them aligned.
International targeting
If you serve several countries in the same language, you do not necessarily need separate versions of every page. A single English site can rank in the USA, the UK, Canada, and elsewhere when its content addresses those audiences. Use hreflang only when you have genuinely different versions of a page for different languages or regions, for example a UK page with UK pricing and a US page with US pricing, and make sure every version links back to the others. Market-specific landing pages, such as our pages for the USA and UK, are often a simpler, more honest way to show relevance.
Performance and Core Web Vitals
Page experience is a ranking consideration, and speed affects conversions regardless. Focus on the three Core Web Vitals:
- Largest Contentful Paint (LCP): make the main image or heading appear quickly. Preload the hero image, serve modern formats such as WebP or AVIF at the right size, and avoid render-blocking resources.
- Interaction to Next Paint (INP): keep the main thread free. Ship less JavaScript, use Server Components where possible, and defer non-essential scripts with
next/script. - Cumulative Layout Shift (CLS): reserve space for images, embeds, and ads by giving them dimensions, and load fonts with
next/fontso text does not jump.
Use next/image with sizes and lazy loading for below-the-fold images. Measure with PageSpeed Insights and the Core Web Vitals report in Search Console, which reflects real users rather than lab tests.
Site structure and internal links
Search engines discover and rank pages partly through internal links. Link from the navigation and footer to your most important pages, link from articles to the relevant service pages, and link related articles to each other. Use descriptive anchor text such as "web development services" rather than "click here". Keep important pages within a few clicks of the home page, and make sure there are no orphan pages that nothing links to.
Accessibility overlaps with SEO
Semantic HTML, one clear h1 per page, a logical heading order, descriptive alt text on meaningful images, and labelled form fields help assistive technology and search engines alike. They are worth doing for both reasons.
Content still decides rankings
Technical SEO removes obstacles. It does not create demand. Pages rank when they answer a searcher's question better than the alternatives: specific, accurate, up to date, and written by people who know the subject. Keep posts current, remove or merge thin pages, and publish evidence of real work, such as case studies and reviews, where clients have agreed to it.
A Next.js SEO checklist
- Static or server rendering for every indexable page; no empty loading shells.
- Unique title, description, and canonical URL on every page.
- One canonical host, with 301 redirects for every variant and secondary domain.
- Generated sitemap with real last-modified dates; robots.txt pointing to it.
- JSON-LD for Organization, Service, BlogPosting, BreadcrumbList, and FAQPage where it matches visible content.
- Optimised images, preloaded hero image,
next/font, minimal client JavaScript. - Descriptive internal links between services, articles, and landing pages.
- Search Console and Bing Webmaster Tools set up and monitored.
Need help?
Alpha Infotech builds fast, search-friendly websites and web apps with React and Next.js for businesses in the USA, the UK, Canada, and Saudi Arabia. See our web development service, or contact us for a review of your current site's technical SEO.