Next.js SEO · Part 7 · App Router

A first SEO-friendly page in Next.js 16

How the App Router turns folders into pages, what a first page looks like, and how to check that its content is in the HTML.

The examples use a fictional JavaScript learning website.

How the App Router works

In Next.js, folders and special files decide which pages exist on a website. For example:

  • app/
  • layout.tsxShared layout
  • page.tsxHome page, /
  • tutorials/
  • page.tsx/tutorials

For example, app/tutorials/page.tsx defines the /tutorials page.

Writing the first page

Create this file:

app/tutorials/page.tsx
export default function TutorialsPage() {
  return (
    <main>
      <h1>JavaScript Tutorials for Beginners</h1>

      <p>
        Learn JavaScript step by step with
        simple examples.
      </p>
    </main>
  );
}

Here is what each important part does:

  • export default tells Next.js which component represents the page.
  • function TutorialsPage() defines a React component.
  • return (...) describes what should appear on the page.
  • <main> marks the main content area.
  • <h1> gives the page a main heading.
  • <p> adds a paragraph.

These are JSX elements, which React uses to describe UI.

What happens when the page opens

When someone visits http://localhost:3000/tutorials, Next.js can send HTML that contains the heading and paragraph. A simplified version of that HTML:

HTML response, simplified
<main>
  <h1>JavaScript Tutorials for Beginners</h1>
  <p>
    Learn JavaScript step by step with
    simple examples.
  </p>
</main>

This matters for SEO because the content is already in the HTML response. A crawler doesn't have to run browser JavaScript to create it.

Verifying the page

In a Next.js 16 project, create the file above, then check the result.

1.Start the dev server

Terminal
npm run dev

2.Open the page

Open http://localhost:3000/tutorials in the browser.

3.Search the page source

Right-click and choose View Page Source, then search for JavaScript Tutorials for Beginners. The heading text should be in the returned HTML.

The browser's find bar searching the page source, with the matching text highlighted

Finding text in View Page Source: the browser's find bar shows how many times it appears.