Next.js App Router represents a massive upgrade for developers building web applications. However, migrating from the Pages Router or a simple React Single Page Application (SPA) introduces shifts in how Search Engines index your content.
In this architectural deep dive, we will explore the essential configurations required to achieve a perfect 100 SEO score on Lighthouse and ensure Google indexes your dynamic pages efficiently.
1. Leverage React Server Components (RSC) By default, pages inside the App Router are **React Server Components**. This is the single most important factor for SEO. Instead of sending an empty HTML shell to the browser (which search crawlers must execute using expensive JavaScript rendering runs), Server Components compile HTML directly on the server.
When a crawler visits your page, it instantly receives fully rendered, semantic HTML containing all your keywords.
2. Implement the Next.js Metadata API Next.js 15+ replaces the older `<Head>` components with a centralized, type-safe **Metadata API**. By exporting a static or dynamic metadata object from your `page.tsx` or `layout.tsx`, you let Next.js handle Open Graph, Twitter cards, and title formats automatically.
// Static Metadata Example
export const metadata: Metadata = {
title: "Services | Truedge",
description: "Enterprise custom software development services.",
};For dynamic paths like `/blog/[slug]`, use the `generateMetadata` function to resolve slugs from your database:
export async function generateMetadata({ params }): Promise<Metadata> {
const post = await blogRepository.getBySlug(params.slug);
return {
title: post.title,
description: post.excerpt,
alternates: {
canonical: `/blog/${post.slug}`,
}
};
}
`/blog/[slug]`3. Add JSON-LD Structured Data Structured schema data (JSON-LD) is crucial for earning search engine rich snippets. By outputting a structured script, you explicitly tell engines what your company represents, who wrote a blog post, or the details of a service.
At Truedge, we integrate the `<script type="application/ld+json">` element directly inside our Server Components, populating values dynamically to match the active route context.
