Menu Close

SEO for React/Next.js Sites: SSR/SSG and Meta Tag Setup

SEO for React/Next.js Sites: SSR/SSG and Meta Tag Setup

“If our site is built with Next.js, will SEO be okay?”

Clients ask us this every time we suggest building their site with Next.js.

The Short Answer

Next.js is a framework that is very strong for SEO. With the right setup, it can perform better in search than a WordPress site. However, if it is set up wrongly, search engines may not index (register) your pages at all.

This article explains SEO for Next.js, from the basics to how to put it into practice.


Contents

Why React on Its Own Is Weak for SEO

The Limits of Client-Side Rendering (CSR)

First, it is a fact that a site built with React alone is weak for SEO.

By default, React uses “client-side rendering (CSR).” A page is displayed in these steps:

  1. The browser receives an almost empty HTML file from the server
  2. The browser downloads the JavaScript files
  3. The JavaScript runs, and the page content is drawn in the browser
Concept diagram — The CSR process: the server sends an almost empty HTML file, and JavaScript builds the content in the browser
Concept diagram — The CSR process: the server sends an almost empty HTML file, and JavaScript builds the content in the browser

The problem is that search engine crawlers (robots that visit and read websites) may not fully support running JavaScript.

Google’s crawler has become better at running JavaScript in recent years. Even so, processing can take time, and some content may not be read. Search engines other than Google (such as Bing’s crawler, which Yahoo! also uses) have even more limited JavaScript support.

Next.js Solves This Problem

Next.js fixes React’s SEO weakness with SSR (server-side rendering) and SSG (static site generation).

Both methods give search engines finished HTML, so crawlers can reliably read the content.


How to Improve SEO with React Alone, Without Next.js

You may already have a site running on React and not be ready to decide on a move to Next.js. Here are three measures you can take while staying on React alone, in order of impact.

1. Output Different Meta Tags for Each Page

The first problem on a React-only site is usually that every page has the same title and description. When the pages appear in search results, people cannot tell them apart, so they do not click. This is the cheapest thing to fix.

With React 19 or later, you can write title and meta directly inside a component, and React moves them into the head element automatically. No extra library is needed.

// React 19 or later
function ServicePage() {
  return (
    <>
      <title>Website Development | Company Name</title>
      <meta name="description" content="A description summarizing this page's content" />
      {/* Page content */}
    </>
  );
}

If you are on React 18 or earlier, you can do the same with a library such as react-helmet-async.

Why You Should Not Stop Here

Meta tags added this way only enter the head element after JavaScript runs in the browser. Google runs JavaScript, so it can read them, but the crawlers that social networks use to fetch OGP do not run JavaScript. This is why no title or image appears when your page is shared on X or Facebook. If you also want traffic from social media, you need to go on to the next step, prerendering.

2. Return Finished HTML with Prerendering

Prerendering means generating the HTML for each page in advance and returning that HTML to crawlers. It fills the gap left by CSR without rewriting your React code.

  • Generate at build time: The HTML for each page is written out when the site is built. Suited to sites with few pages whose content does not change much
  • Generate on access: Only visits from crawlers are detected, and they receive the pre-generated HTML. Use this if you have many pages or the content changes often

The drawback of prerendering is that you end up running two setups. Regular users get CSR and crawlers get pre-generated HTML, and you have to keep it that way. Every time you add a page, you need to configure and test it.

3. When to Move to Next.js

Measures 1 and 2 only treat the symptoms. If any of the following applies to you, considering a migration will end up costing less time and money than piling on more workarounds.

SituationDecision
A few dozen pages, and the number will not grow muchReact alone plus meta tag setup is enough
You want traffic from social media sharesPrerendering or more is needed
Pages keep being added, such as blog posts or case studiesConsider moving to Next.js
You want search traffic to be a pillar of your businessMoving to Next.js is recommended

SSR vs. SSG vs. ISR: Understanding Them from an SEO Perspective

SSR (Server-Side Rendering)

SSR (Server Side Rendering) is a method where the server generates HTML and returns it every time a user visits.

  • How it works: Request → server generates HTML → returned to the user
  • Effect on SEO: Strong for SEO because crawlers receive finished HTML
  • Best for: Pages whose content changes for each user, and pages that need real-time information

SSG (Static Site Generation)

SSG (Static Site Generation) is a method where HTML is generated in advance at build time (the stage where the site is prepared for release).

  • How it works: HTML generated at build time → placed on a CDN → delivered to users
  • Effect on SEO: Finished HTML is served quickly from a CDN, which makes it the best option for SEO
  • Best for: Pages that are rarely updated, such as company profiles, service pages and blog posts

ISR (Incremental Static Regeneration)

ISR (Incremental Static Regeneration) is an evolved version of SSG. It automatically regenerates static pages at set intervals.

  • How it works: HTML generated at build time → regenerated in the background at the interval you set → replaced with the latest HTML
  • Effect on SEO: Keeps the speed benefit of SSG while keeping information up to date
  • Best for: Pages that are updated regularly, such as blog posts, product information and news
Concept diagram — SSR, SSG and ISR compared side by side, with a timeline showing when each one generates the page (on access / at build time / at regular intervals)
Concept diagram — SSR, SSG and ISR compared side by side, with a timeline showing when each one generates the page (on access / at build time / at regular intervals)

Recommended Choices for SEO

Page typeRecommended methodReason
Home pageSSG or ISRFast display matters. With ISR, the latest information can also be shown
Company profile / service pagesSSGRarely updated, so speed comes first
Blog postsSSG + ISRGenerated at build time and replaced with ISR when updated
News listISRRegenerated each time a new post is added
Search results pageSSRGenerated dynamically based on what the user enters
My page (account page)CSRNo SEO needed. Dynamic content shown after the user logs in
If in Doubt, Start with SSG

For a small or medium-sized company’s corporate site, the setup with the best balance of speed, SEO and day-to-day running is SSG for content pages, combined with ISR only for the parts that are updated often.


Setting Up Meta Tags and OGP in Next.js

Setting the Title Tag and Description

The title and description shown in search results are the most basic elements of SEO.

With the App Router in Next.js, you can set them simply with a metadata object.

// app/page.tsx
export const metadata = {
  title: "Company Name | A title that sums up your service",
  description: "Summarize the page in 120 characters or fewer. Write a description that makes searchers want to click",
};

With the Pages Router, use next/head.

import Head from "next/head";

export default function Page() {
  return (
    <>
      <Head>
        <title>Company Name | Title</title>
        <meta name="description" content="Page description" />
      </Head>
      {/* Page content */}
    </>
  );
}

Set Unique Meta Tags for Each Page

What matters for SEO is not using the same title and description on every page.

Set unique meta tags that match the content of each page. For blog posts, you can set the post title and summary dynamically using data fetched from your CMS.

Generate Meta Tags for Post Pages Dynamically

For content where the number of pages changes, such as a blog or case studies, you cannot write meta tags by hand for each page. With the App Router, use generateMetadata to feed the content fetched from your CMS straight into the title and description.

// app/blog/[slug]/page.tsx
export async function generateMetadata({ params }) {
  const post = await getPost(params.slug);
  return {
    title: post.title,
    description: post.excerpt,
    openGraph: {
      title: post.title,
      description: post.excerpt,
      images: [post.eyecatch],
    },
  };
}

No setup work is needed as more posts are added. This setup is also worth having because it keeps meta tags from being left empty as the site is run day to day.

Do You Need the next-seo Library?

If you look up SEO for Next.js, you will often see a library called next-seo. In short, if you are building a new site with the App Router, you basically do not need it.

next-seo became popular in the Pages Router era as a way to make managing meta tags easier. Back then, you had to list tags in next/head on each page, and the library reduced that work. In today’s App Router, the metadata and generateMetadata features described above do the same job as standard.

SituationChoice
Building a new site with the App RouterUse the standard Metadata API (next-seo is not needed)
Running an existing Pages Router sitenext-seo is useful. No need to force its removal
Migrating from the Pages Router to the App RouterSwitch each page to the standard API as you migrate it

Adding a library also means taking on running costs: keeping up with its updates and with new versions of Next.js itself. Where the standard features are enough, choosing them will hold up better over time.


Do you have questions about building a site with Next.js or about SEO?

Web制作・システム開発は
First CHにお任せください

「こんなWebサイトが欲しい」「このシステムは実現できる?」——
現役エンジニアが直接お話を伺い、最適な進め方をご提案します。

「まだ構想段階」「費用感だけ知りたい」というご相談も歓迎です。

OGP (Social Sharing Settings): Getting the Most Traffic from Social Media

What Is OGP?

OGP (Open Graph Protocol) is a way to control the image, title and description shown when your site’s URL is shared on social media.

When you share a URL on Facebook, X (formerly Twitter), LINE and similar services, a card-style preview appears. OGP controls what this preview contains.

To check how it looks after setup, you can use our free OGP Checker (First CH Tools). Just enter a URL to preview the card shown when it is shared.

Setting Up OGP in Next.js

With the App Router, you can set OGP in the same metadata object.

export const metadata = {
  title: "Page title",
  description: "Page description",
  openGraph: {
    title: "Title for social media shares",
    description: "Description for social media shares",
    images: ["/og-image.jpg"],
    type: "website",
    url: "https://example.com/page",
  },
  twitter: {
    card: "summary_large_image",
    title: "Title for X (formerly Twitter)",
    description: "Description for X (formerly Twitter)",
    images: ["/og-image.jpg"],
  },
};

Tips for OGP Images

The OGP image has a big effect on how your page looks on social media. Keep the following points in mind.

  • Recommended size: 1200 x 630px
  • File format: JPEG or PNG
  • File size: 1MB or less
  • If you put text in the image, center it (because some social networks crop the image)

Optimizing for Crawlers: Sitemaps, robots.txt and Structured Data

Generating a Sitemap Automatically

A sitemap (sitemap.xml) is a file that tells search engines which pages are on your site.

In Next.js (App Router), you can generate a sitemap automatically by creating an app/sitemap.ts file.

// app/sitemap.ts
export default function sitemap() {
  return [
    { url: "https://example.com", lastModified: new Date() },
    { url: "https://example.com/about", lastModified: new Date() },
    { url: "https://example.com/blog", lastModified: new Date() },
    // You can also fetch the post list from your CMS and generate this dynamically
  ];
}
A Sitemap Is Not Created Automatically

In WordPress, a plugin can generate it automatically, so you do not have to think about it. In Next.js, you need to set it up yourself. Be sure to add it to your pre-launch checklist.

Setting Up robots.txt

robots.txt is a file that tells search engine crawlers “you may crawl this page” or “please do not crawl this page.”

// app/robots.ts
export default function robots() {
  return {
    rules: { userAgent: "*", allow: "/", disallow: "/admin/" },
    sitemap: "https://example.com/sitemap.xml",
  };
}

Structured Data: Improving How You Appear in Search Results

What Is Structured Data?

Structured data is a way to tell search engines what the content of a page means.

For example, you describe information such as “this is company information,” “this is a blog post” or “this is an FAQ” in JSON-LD format.

When it is set up correctly, rich snippets (results that stand out more than usual) may appear in Google search results.

Adding Structured Data in Next.js

In Next.js, you embed JSON-LD using a <script> tag.

export default function BlogPost({ post }) {
  const jsonLd = {
    "@context": "https://schema.org",
    "@type": "Article",
    headline: post.title,
    datePublished: post.publishedAt,
    author: { "@type": "Organization", name: "First CH LLC" },
  };

  return (
    <>
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
      />
      {/* Post content */}
    </>
  );
}

Structured Data a Small Business Site Should Set Up

You do not need to set up every type of structured data. The high-priority types for a corporate site are these:

TypeUsePriority
OrganizationCompany information (name, logo, contact details)High
LocalBusinessAddress and business hours of a shop or officeHigh (if you have a physical location)
BreadcrumbListBreadcrumb navigationHigh
ArticleBlog postsMedium
FAQFrequently asked questionsMedium
WebSiteInformation about the whole siteLow (as a basic setting)

You can generate JSON-LD for Organization, LocalBusiness, FAQ and more by filling in a form in our free JSON-LD Generator (First CH Tools). We recommend it because it prevents the syntax mistakes that happen when writing by hand.


Image Optimization: Using Next.js’s Built-In Features

Using the next/image Component

Next.js comes with the next/image component as standard, which optimizes images automatically.

Its main features are:

  • Automatic resizing: Optimizes images to match the display size
  • WebP/AVIF conversion: Automatically converts images to modern formats
  • Lazy loading: Loads images when they come into view on the screen
  • Preventing CLS (layout shift): Reserves the image’s display area in advance

These directly improve Core Web Vitals, which are an SEO ranking factor.

Do Not Forget the alt Attribute

An image’s alt attribute (alternative text) is important information that helps search engines understand what the image shows.

<Image src="/office.jpg" alt="Exterior of the First CH LLC office" width={800} height={600} />

Instead of just writing “image,” set text that describes the content of the image specifically.


Summary: Common Mistakes and an SEO Checklist

Common Mistakes and How to Avoid Them

Mistake 1: Making Every Page CSR

If you use Next.js with only React knowledge, every page can end up using CSR (client-side rendering).

Fix: Use SSG or SSR for content pages, and use CSR only for user-specific pages such as admin screens and account pages.

Mistake 2: Forgetting to Set Up a Sitemap

In WordPress, a plugin generates it automatically, so you do not think about it. In Next.js, you have to set up the sitemap yourself.

Fix: Add checks for the sitemap and robots.txt to your pre-launch checklist.

Mistake 3: Dynamic Meta Tags Are Not Being Generated

Sometimes every blog post’s title and description are left at the same default values.

Fix: When fetching data from the CMS, add code that puts each post’s title and description into metadata.

SEO Checklist

ItemImportanceWhat to do
Choosing SSG/SSR correctlyCriticalServe content pages with SSG or SSR
Setting the title and descriptionCriticalSet unique meta tags on every page
OGP setupHighOptimize how pages look when shared on social media
Sitemap generationHighGenerate sitemap.xml automatically
robots.txt setupHighGive crawlers the right instructions
Structured dataMediumAim for rich snippets
Image optimizationMediumImprove Core Web Vitals with next/image
alt attributeMediumSet alternative text for images

When set up correctly, Next.js is a framework that is very strong for SEO. However, unlike WordPress, it is not a case of “install a plugin and you are done.” It requires technical understanding and proper implementation.

If you want to build a site with Next.js that is strong for SEO, we can support you all the way from choosing the technology to designing for SEO.


Related articles:


At First CH, SEO is included as standard when we build sites with Next.js. If you are looking for a site built with both technical skill and SEO know-how, please feel free to contact us.

Web制作・システム開発は
First CHにお任せください

「こんなWebサイトが欲しい」「このシステムは実現できる?」——
現役エンジニアが直接お話を伺い、最適な進め方をご提案します。

「まだ構想段階」「費用感だけ知りたい」というご相談も歓迎です。

Share this article
Contents