GitHubLinkedInResume
Back to Blog

Mastering SEO in Next.js App Router

By Bon Andre T. Opina5 min read

Search Engine Optimization (SEO) isn't just an afterthought you slap onto a completed project. It is an architectural decision that must be deeply integrated into your initial setup, especially when migrating to or using the modern Next.js App Router.

The App Router Paradigm Shift

The shift from the Pages Router to the App Router introduced a fundamentally new way of dealing with Metadata in Next.js. We moved from injecting `<Head>` components throughout our trees towards utilizing the built-in `export const metadata` API. This enforced a much stronger typed, server-first approach to generating critical tags before the client even boots.

Dynamic sitemaps and robots.txt

Static `sitemap.xml` files are fine for simple landing pages, but real engineering requires dynamic crawling. By returning `MetadataRoute.Sitemap` representations in `sitemap.ts`, we can pull right from our databases or CMS at build time (or on-demand with ISR) to serve constantly updated indices directly to Googlebot.

Semantic HTML and Structured Data

Google doesn't just read your meta tags. It reads the DOM structure and injects meaning based on JSON-LD schemas. Using a simple globally injected `JsonLd` component across pages like our FAQ, Blog Articles, and Contact endpoints allows us to build Rich Snippets gracefully inside our React trees without hacky script injections.

SEO is an ongoing battle, but a solid foundation inside Next.js gives you a monumental head start over standard SPAs.

Share this article:
Contact Me Now