DEV Community

Cover image for How Do You Build a Fast, SEO-Friendly Landing Page with Next.js?
Muhammad Afzal Kalwar
Muhammad Afzal Kalwar

Posted on

How Do You Build a Fast, SEO-Friendly Landing Page with Next.js?

To build a fast, SEO-friendly landing page with Next.js, render it as a Server Component, set metadata with the Metadata API, optimize images with next/image, add JSON-LD structured data, and keep client-side JavaScript to a minimum. Below is a practical setup using the App Router.

Why does Next.js suit landing pages?

Landing pages are mostly static content. The App Router renders Server Components to HTML on the server (or at build time), so crawlers and users get full content immediately, with little JavaScript to download.

How do you set metadata and a canonical URL?

Export a metadata object from app/page.tsx:

import type { Metadata } from "next";

export const metadata: Metadata = {
  title: "Acme Scheduler: Book meetings without back-and-forth",
  description: "A short, specific description of what the product does and who it is for.",
  alternates: { canonical: "https://example.com/" },
  openGraph: {
    title: "Acme Scheduler",
    description: "Book meetings without back-and-forth.",
    url: "https://example.com/",
    images: ["/og.png"],
  },
};
Enter fullscreen mode Exit fullscreen mode

Give every page its own self-referencing canonical. A canonical pointing every subpage to the homepage can stop those pages from being indexed.

How do you keep images from hurting performance?

Use next/image with explicit dimensions and priority only for the above-the-fold hero image, and always write meaningful alt text:

import Image from "next/image";

<Image src="/hero.png" alt="Dashboard showing a weekly meeting calendar" width={1200} height={700} priority />
Enter fullscreen mode Exit fullscreen mode

Explicit dimensions prevent layout shift (CLS).

How do you add structured data?

JSON-LD helps search engines and AI answer engines understand the page:

const jsonLd = {
  "@context": "https://schema.org",
  "@type": "SoftwareApplication",
  name: "Acme Scheduler",
  applicationCategory: "BusinessApplication",
};

export default function Page() {
  return (
    <>
      <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />
      {/* page content */}
    </>
  );
}
Enter fullscreen mode Exit fullscreen mode

If you add an FAQ section, mark it up with FAQPage only when the questions are visible on the page.

How do you limit client-side JavaScript?

Keep components as Server Components by default. Add "use client" only to small interactive pieces such as a form or menu. Load third-party scripts with next/script and strategy="lazyOnload".

How do you add a sitemap and robots file?

// app/sitemap.ts
import type { MetadataRoute } from "next";

export default function sitemap(): MetadataRoute.Sitemap {
  return [{ url: "https://example.com/", lastModified: new Date() }];
}
Enter fullscreen mode Exit fullscreen mode

Then verify with Lighthouse or PageSpeed Insights and measure real results rather than assuming them.

FAQ

Do I need SSR for SEO? No. Static generation or server rendering both deliver crawlable HTML; what matters is that content is in the initial HTML.

Pages Router or App Router? The App Router's Metadata API and Server Components make this simpler for new projects.

How do I check it works? View the page source for your content, test with PageSpeed Insights, and inspect the URL in Google Search Console.


I'm Muhammad Afzal, a Python developer building web projects at INDUS Web Agency.

Top comments (0)