Menu · Start here
Start here

Quickstart: a server-rendered Next.js page

Build a server-rendered Next.js area page with listing cards, pagination, head tags, JSON-LD and the board disclaimers, step by step, on your own live data.

View as Markdownopenapi.json

This quickstart builds one server-rendered area page in a Next.js App Router site: the listings for a neighborhood, with real links to each listing, the head tags and JSON-LD the API returns, and the disclaimers every board requires. It uses the SDK @ruuster/idx and the recipe components @ruuster/idx-recipes. The same files are in the examples repo, so you can also start from there.

You need Node.js 18.17 or later and your secret key. A free sandbox secret key works: press Get API keys at the top of these docs. Your server calls the API with it, so localhost works. Add any other domain you build on under Keys and domains in your console.

Steps

  1. Create a Next.js site, or open yours: npx create-next-app@latest my-site --ts --app, then cd my-site.

  2. Install the two packages: npm install @ruuster/idx @ruuster/idx-recipes. They work as installed, with nothing to add to next.config.mjs.

  3. Create .env.local in the site's root with these lines, using your own values: IDX_SECRET_KEY=idx_sk_your_key, SITE_ORIGIN=http://localhost:3000 and SITE_NAME=Your Brokerage. Next.js keeps names without NEXT_PUBLIC_ on the server, which is where the secret key belongs. Leave IDX_BASE_URL out, so the SDK calls the Ruuster Listings API. For the map, add NEXT_PUBLIC_GOOGLE_MAPS_KEY and NEXT_PUBLIC_GOOGLE_MAP_ID with your own Google values. Get your Google Maps key shows how to get both in about 15 minutes. Without them, every page works and the map stays hidden.

  4. Create your site's settings, lib/site.ts, and the client every server file shares, lib/idx.ts:

lib/site.ts

// Your site's own settings. Every page, form and sitemap reads them from here.
import type { DetailAgent } from "@ruuster/idx-recipes";

/** Your brokerage's name as visitors see it. It is also the lead source your CRM shows. */
export const SITE_NAME = process.env.SITE_NAME || "Your Brokerage";

/** Your site's origin, with no trailing slash, for canonical URLs, sitemaps and pageHref. */
export const SITE_ORIGIN = (process.env.SITE_ORIGIN || "http://localhost:3000").replace(/\/+$/, "");

/** Where every form posts its lead: your own server route, which sends it to your CRM. */
export const LEADS_ACTION = "/api/leads/fub";

/** Your search page. The listing page's Back link and its X return here. */
export const SEARCH_PATH = "/search";

/** Your listing page URL template. The API builds each card's href from it. */
export const DETAIL_HREF = "/homes/{slug}";

/** A collection you curate in Ruuster for the homepage strip. Leave it null to show your own listings. */
export const FEATURED_COLLECTION_ID: string | null = null;

/** The consent sentence beside the contact box on every form. Edit it with your own wording. */
export const CONSENT_TEXT = `I agree that ${SITE_NAME} may contact me by phone, text or email about this request.`;

/** The consent sentence beside the separate listing-alerts box. */
export const ALERTS_CONSENT_TEXT = "Email me new listings like this one. I can unsubscribe at any time.";

/**
 * The agent or office your listing pages offer for questions and tours: the contact card, the
 * mobile action bar and the contact form are about this person. Use your own agent or your office's
 * team inbox, never the listing agent from the MLS. Leave a value unset and the page leaves that
 * line out; with no name, the buttons read "Contact an agent".
 */
export const SITE_AGENT: DetailAgent = {
  name: process.env.SITE_AGENT_NAME || null,
  photoUrl: process.env.SITE_AGENT_PHOTO_URL || null,
  phone: process.env.SITE_AGENT_PHONE || null,
  email: process.env.SITE_AGENT_EMAIL || null,
  license: process.env.SITE_AGENT_LICENSE || null,
  brokerage: SITE_NAME,
};

/** An absolute URL on your site for a path such as "/homes/123-main-st-…". */
export function absoluteUrl(path: string): string {
  if (/^https?:\/\//i.test(path)) return path;
  return `${SITE_ORIGIN}${path.startsWith("/") ? "" : "/"}${path}`;
}

lib/idx.ts

// The one Ruuster Listings API client this site uses on the server.
// IDX_SECRET_KEY never reaches the browser: only server components and route handlers import this file.
import "server-only";
import { createClient } from "@ruuster/idx";
import { DETAIL_HREF, SITE_ORIGIN } from "@/lib/site";

export const idx = createClient({
  secretKey: process.env.IDX_SECRET_KEY,
  // Leave IDX_BASE_URL unset, so the client calls the Ruuster Listings API itself.
  baseUrl: process.env.IDX_BASE_URL || undefined,
  detailHref: DETAIL_HREF,
  siteOrigin: SITE_ORIGIN,
  // Next.js keeps each answer for 5 minutes; the listing-change webhook refreshes pages sooner.
  next: { revalidate: 300 },
});

/**
 * GET /v1/meta: your brand variables, capabilities, compliance rules and organization block.
 * Next.js answers repeated identical requests in one render from memory, so every page may call it.
 */
export function getMeta() {
  return idx.meta();
}

export { fmt, listingPath, parseListingSlug, toMetadata } from "@ruuster/idx";
  1. Create your list of areas, content/areas.ts. Each area keeps the where object /v1/suggest returned for it, so a page never builds a location by hand:

content/areas.ts

// The places you sell in: one entry per area page. This file is your own content.
//
// `where` is the row GET /v1/suggest answered for the place, copied in once and never edited by
// hand. To get one, run (with your secret key in your shell, never in a chat):
//   curl -s "https://idx.ruuster.com/v1/suggest?q=Midtown&groups=neighborhood" -H "Authorization: Bearer $IDX_SECRET_KEY"
// and paste the `where` object of the row you want.
// The two areas below are example rows; replace them with your own.
import type { WhereObject } from "@ruuster/idx";

export type AreaQuestion = { question: string; answer: string };

export type Area = {
  /** The URL segment: /neighborhoods/<slug>. */
  slug: string;
  /** The name you show in headings and links. */
  name: string;
  /** The /v1/suggest row for this place, unchanged. */
  where: WhereObject;
  /** Publish /neighborhoods/<slug>/sold. The page also checks that your boards show sold data. */
  soldPage: boolean;
  /** Your agents' own words about the area: the streets, the housing, what buyers ask about. */
  ownWords: readonly string[];
  /** Questions you answer yourself, shown after the market questions. Each answer starts with the answer. */
  questions: readonly AreaQuestion[];
};

export const AREAS: readonly Area[] = [
  {
    slug: "midtown",
    name: "Midtown",
    where: { label: "Atlanta, GA Midtown", value: "a0000000-0000-4000-8000-000000000001", source: "neighborhood", data: { state: "GA" } },
    soldPage: true,
    ownWords: [
      "Midtown mixes high-rise condos along Peachtree Street with brick bungalows on the quieter side streets east of the park.",
      "Most condo buildings here have a monthly association fee that covers the pool, the gym and building insurance, so ask for the budget early.",
    ],
    questions: [
      {
        question: "What kinds of homes are in Midtown?",
        answer: "Mostly condos in mid-rise and high-rise buildings, with single-family homes and townhomes on the side streets.",
      },
    ],
  },
  {
    slug: "atlanta",
    name: "Atlanta",
    where: { label: "Atlanta, GA", value: "Atlanta", source: "crm-system", data: { state: "GA", city: "Atlanta" }, city: "Atlanta", state: "GA" },
    soldPage: true,
    ownWords: ["Atlanta's listings range from downtown lofts to wooded lots inside the Perimeter, and every neighborhood has its own page on this site."],
    questions: [],
  },
];

/** The area the site-wide pages (open houses, price reduced, new construction) search in. */
export const MARKET_AREA: Area = AREAS[AREAS.length - 1];

export function areaBySlug(slug: string): Area | null {
  return AREAS.find((a) => a.slug === slug) ?? null;
}
  1. Create lib/area-query.ts, which turns an area and the page's URL into one search, and content/answer.ts, which writes the dated answer sentence from /v1/market:

lib/area-query.ts

// Turns an area and the page's URL into the search the page sends.
// The area fixes the location; the visitor's URL may add filters, a sort order and a page.
import { fromSearchParams, type SearchParamsInput, type SearchQuery } from "@ruuster/idx";
import type { Area } from "@/content/areas";

/** A search that answers listing cards (the default view). */
export type CardQuery = Omit<SearchQuery, "view">;

/** URL names a visitor may not change on an area page: the location, the key-level options and the page size. */
const FIXED = ["where", "bbox", "polygon", "boundariesId", "zip", "city", "state", "shape", "ownListings", "agent", "office", "view", "detailHref", "pageHref", "indexable", "limit"] as const;

/** Results per page on every results page of this site. */
export const PAGE_SIZE = 24;

/** The visitor's filters, sort and page from the URL, without anything that would change the location. */
export function visitorQuery(searchParams: SearchParamsInput): CardQuery {
  const q: Record<string, unknown> = { ...fromSearchParams(searchParams) };
  for (const k of FIXED) delete q[k];
  return q as CardQuery;
}

/** The API's default order; there is no "newest" sort. */
/** /neighborhoods/<slug>: the area's active listings in the API's recommended order unless the visitor picked another. */
export function areaQuery(area: Area, searchParams: SearchParamsInput): CardQuery {
  return {
    ...visitorQuery(searchParams),
    status: "active",
    where: area.where,
    limit: PAGE_SIZE,
    pageHref: `/neighborhoods/${area.slug}`,
  };
}

/** /neighborhoods/<slug>/sold: homes sold in the last 6 months, most recent first. */
export function soldQuery(area: Area, searchParams: SearchParamsInput): CardQuery {
  const v = visitorQuery(searchParams);
  return {
    ...v,
    status: "closed",
    soldPeriod: "6m",
    sort: "close_date_desc",
    where: area.where,
    limit: PAGE_SIZE,
    pageHref: `/neighborhoods/${area.slug}/sold`,
  };
}

/** True when the query names a location (or own, agent or office listings), which every search needs. */
export function hasLocation(q: SearchQuery): boolean {
  const where = Array.isArray(q.where) ? q.where.length > 0 : Boolean(q.where);
  return where || Boolean(q.bbox || q.polygon || q.boundariesId || q.zip || q.city || q.state || q.shape || q.ownListings || q.agent || q.office);
}

/**
 * True when at least one of your boards shows sold data (GET /v1/meta capabilities.sold).
 * Sold pages are published only then.
 */
export function showsSoldData(capabilities: Readonly<Record<string, unknown>> | null | undefined): boolean {
  const sold = capabilities?.sold;
  return Array.isArray(sold) && sold.some((b) => typeof b === "object" && b !== null && (b as { allowed?: unknown }).allowed === true);
}

content/answer.ts

// The answer at the top of an area page: one sentence with today's numbers and the date, then the
// questions people ask about the area, each answered in its first sentence (plain market facts only).
import type { MarketData, MarketSeries } from "@ruuster/idx";
import { fmt, idx } from "@/lib/idx";
import type { Area, AreaQuestion } from "@/content/areas";

export type AreaAnswer = {
  /** The lead sentence: homes for sale, prices, days on market, the date. */
  lead: string;
  /** Market questions with their answers (a question whose number is missing is left out). */
  questions: AreaQuestion[];
  /** The date the numbers are from (ISO). */
  asOf: string;
};

const MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

/** "2026-10" → "October 2026". */
export function monthName(month: string): string {
  const m = /^(\d{4})-(\d{2})$/.exec(month);
  if (!m) return month;
  return `${MONTHS[Number(m[2]) - 1] ?? m[2]} ${m[1]}`;
}

/** The latest month of a series that has a value, or null. */
export function latestPoint(s: MarketSeries | undefined): { month: string; value: number } | null {
  if (!s) return null;
  for (let i = s.series.length - 1; i >= 0; i--) {
    const p = s.series[i];
    if (p.value !== null) return { month: p.month, value: p.value };
  }
  return null;
}

/** Builds the answer from a GET /v1/market answer. Pure: the page passes the data in. */
export function answerFromMarket(market: MarketData, areaName: string): AreaAnswer {
  const m = market.measures;
  const updated = `Updated ${fmt.date(market.asOf)}.`;
  const sentences: string[] = [];

  const inventory = m.activeInventory?.current ?? null;
  const asking = m.medianListPrice?.current ?? null;
  if (inventory !== null && asking !== null) {
    sentences.push(`${areaName} has ${fmt.count(inventory)} ${inventory === 1 ? "home" : "homes"} for sale today, at a median asking price of ${fmt.usd(asking)}.`);
  } else if (inventory !== null) {
    sentences.push(`${areaName} has ${fmt.count(inventory)} ${inventory === 1 ? "home" : "homes"} for sale today.`);
  }

  const sold = latestPoint(m.medianSoldPrice);
  const ratio = m.listToSaleRatio?.current ?? null;
  const dom = m.medianDaysOnMarket?.current ?? null;
  if (sold) {
    let s = `Homes that sold in ${monthName(sold.month)} closed at a median of ${fmt.usd(sold.value)}`;
    if (ratio !== null) s += `, or ${(ratio * 100).toFixed(1)}% of asking`;
    if (dom !== null) s += `, after ${fmt.count(dom)} days on market`;
    sentences.push(`${s}.`);
  }
  sentences.push(updated);

  const questions: AreaQuestion[] = [];
  if (sold) {
    const change = fmt.change(m.medianSoldPrice, 12);
    const year = Number(sold.month.slice(0, 4)) - 1;
    const since = change ? ` That is a change of ${change} from ${monthName(`${year}${sold.month.slice(4)}`)}.` : "";
    questions.push({ question: `What is the median home price in ${areaName}?`, answer: `${fmt.usd(sold.value)} for homes sold in ${monthName(sold.month)}.${since}` });
  } else if (asking !== null) {
    questions.push({ question: `What is the median home price in ${areaName}?`, answer: `The median asking price of the homes for sale today is ${fmt.usd(asking)}.` });
  }
  const supply = m.monthsOfSupply?.current ?? null;
  if (dom !== null || supply !== null) {
    const parts: string[] = [];
    if (dom !== null && sold) parts.push(`The median home sold in ${fmt.count(dom)} days in ${monthName(sold.month)}.`);
    else if (dom !== null) parts.push(`The median home sold in ${fmt.count(dom)} days.`);
    if (supply !== null) parts.push(`At the current pace of sales, the homes for sale today would sell in ${fmt.count(supply)} months.`);
    questions.push({ question: `How fast are homes selling in ${areaName}?`, answer: parts.join(" ") });
  }
  const fresh = latestPoint(m.newListings);
  if (inventory !== null) {
    let a = `${fmt.count(inventory)} ${inventory === 1 ? "home is" : "homes are"} for sale today.`;
    if (fresh) a += ` ${fmt.count(fresh.value)} new ${fresh.value === 1 ? "listing" : "listings"} came on the market in ${monthName(fresh.month)}.`;
    questions.push({ question: `How many homes are for sale in ${areaName}?`, answer: a });
  }

  return { lead: sentences.join(" "), questions, asOf: market.asOf };
}

/** GET /v1/market for the area (13 months, so the change against a year earlier has both ends), then the answer. */
export async function areaAnswer(area: Area): Promise<{ answer: AreaAnswer; market: MarketData } | null> {
  const r = await idx.market({ where: area.where, months: 13 });
  if (!r.ok) return null;
  return { answer: answerFromMarket(r.data, area.name), market: r.data };
}
  1. Create what every results page shares: lib/results.ts (what the page does with each failure, and its metadata) and components/results.tsx (the cards, page links, map, disclaimers and JSON-LD):

lib/results.ts

// What a page does with an API answer that is not a success, and the head tags of a results page.
import { toMetadata, type IdxFailure, type PageHead } from "@ruuster/idx";

/** The error codes after which the page should not exist at all (HTTP 404). */
const PAGE_DOES_NOT_EXIST = new Set(["not_found", "boundary_not_found", "agent_not_found", "shape_not_found", "mls_not_in_scope", "location_not_supported", "filter_not_supported", "sold_not_permitted", "own_listings_unconfigured"]);

/**
 * "not_found": answer 404 (call notFound()).
 * "throw": throw, so Next.js keeps serving the last good page and tries again later (429, 503, network).
 * "empty": render the page with no listings (a filter value the visitor typed was refused).
 */
export function failureAction(r: Pick<IdxFailure, "status" | "error">): "not_found" | "throw" | "empty" {
  if (r.status === 404 || PAGE_DOES_NOT_EXIST.has(r.error.code)) return "not_found";
  if (r.error.retryable || r.status === 0 || r.status === 429 || r.status >= 500) return "throw";
  return "empty";
}

/** The number of result pages: the API's own `pages` when the answer carries it. */
export function pageCount(data: { total: number; limit: number; pages?: number }): number {
  if (typeof data.pages === "number") return data.pages;
  if (data.total <= 0 || data.limit <= 0) return 0;
  // The API pages through the first 2,000 results of a search.
  return Math.min(Math.ceil(data.total / data.limit), Math.floor(2000 / data.limit));
}

/** Next.js metadata for a results page: the head the API built, or a plain title until it has one. */
export function resultsMetadata(head: PageHead | undefined, fallbackTitle: string) {
  return head ? toMetadata(head) : { title: fallbackTitle };
}

components/results.tsx

// The body of every results page: cards, pagination, the map, the MLS disclaimers and the JSON-LD.
import type { IdxSuccess, ListingCard, SearchResult } from "@ruuster/idx";
import { AreaMap, JsonLd, ListingGrid, MlsDisclaimers, Pagination } from "@ruuster/idx-recipes";
import { idx } from "@/lib/idx";
import { pageCount } from "@/lib/results";

type Props = {
  r: IdxSuccess<SearchResult<ListingCard>>;
  /** The page's own path, for the pagination links. */
  basePath: string;
  searchParams?: Readonly<Record<string, string | readonly string[] | undefined>>;
  /** GA4 item_list_name for the cards. */
  listName: string;
  emptyText?: string;
  /** Draw the map (needs NEXT_PUBLIC_GOOGLE_MAPS_KEY). */
  map?: boolean;
  /** The page's own path and query, which the map's "Search this area" and drawing tools start from. */
  searchHref?: string;
};

export async function Results({ r, basePath, searchParams, listName, emptyText, map = true, searchHref }: Props) {
  const mls = r.meta.mls;
  const mapsKey = process.env.NEXT_PUBLIC_GOOGLE_MAPS_KEY;
  // The outline of the searched area, when the search was a boundary and the map is on.
  const b = map && mapsKey && r.data.boundary ? await idx.boundary(r.data.boundary.id) : null;
  const boundary = b?.ok ? b.data.geometry : null;
  return (
    <>
      <ListingGrid listings={r.data.listings} mls={mls} ga4ListName={listName} emptyText={emptyText ?? "No homes match this search right now."} />
      <Pagination page={r.data.page} pages={pageCount(r.data)} basePath={basePath} searchParams={searchParams} />
      {map && mapsKey && r.data.listings.length > 0 ? (
        <AreaMap googleMapsKey={mapsKey} mapId={process.env.NEXT_PUBLIC_GOOGLE_MAP_ID || null} viewport={r.data.viewport} boundary={boundary} boundaryKind={b?.ok ? b.data.kind : null} listings={r.data.listings} mls={mls} searchHref={searchHref} drawing={Boolean(searchHref)} />
      ) : null}
      <MlsDisclaimers mls={mls} asOf={r.meta.freshness.asOf} />
      <JsonLd docs={r.data.jsonLd ?? []} />
    </>
  );
}
  1. Create the page, app/neighborhoods/[area]/page.tsx:

app/neighborhoods/[area]/page.tsx

// /neighborhoods/<area>: an area page built to rank and to be quoted by AI assistants.
// Top to bottom: the one-sentence answer with today's numbers and the date, the market tiles, the
// questions people ask (each an <h2> answered in its first sentence), your own words, then the
// listings, pagination, the map, the MLS disclaimers and the JSON-LD.
import Link from "next/link";
import { notFound } from "next/navigation";
import { Filters, MarketStats } from "@ruuster/idx-recipes";
import { Results } from "@/components/results";
import { areaAnswer } from "@/content/answer";
import { AREAS, areaBySlug } from "@/content/areas";
import { getMeta, idx } from "@/lib/idx";
import { areaQuery, showsSoldData } from "@/lib/area-query";
import { failureAction, resultsMetadata } from "@/lib/results";

export const revalidate = 300;

type Props = { params: { area: string }; searchParams: Record<string, string | string[] | undefined> };

export function generateStaticParams() {
  return AREAS.map((a) => ({ area: a.slug }));
}

export async function generateMetadata({ params, searchParams }: Props) {
  const area = areaBySlug(params.area);
  if (!area) return {};
  const r = await idx.search(areaQuery(area, searchParams));
  return r.ok ? resultsMetadata(r.data.head, `Homes for sale in ${area.name}`) : {};
}

export default async function AreaPage({ params, searchParams }: Props) {
  const area = areaBySlug(params.area);
  if (!area) notFound();
  const q = areaQuery(area, searchParams);
  const [r, answer, meta] = await Promise.all([idx.search(q), areaAnswer(area), getMeta()]);
  if (!r.ok) {
    const action = failureAction(r);
    if (action === "not_found") notFound();
    throw new Error(`Listings API ${r.status} ${r.error.code}`);
  }
  const sold = area.soldPage && meta.ok && showsSoldData(meta.data.capabilities);
  return (
    <main>
      <nav aria-label="Breadcrumb">
        <Link href="/neighborhoods">Neighborhoods</Link> › {area.name}
      </nav>
      <h1>{`Homes for sale in ${area.name}`}</h1>
      {answer ? <p>{answer.answer.lead}</p> : null}
      {answer ? <MarketStats market={answer.market} /> : null}
      {answer?.answer.questions.map((x) => (
        <section key={x.question}>
          <h2>{x.question}</h2>
          <p>{x.answer}</p>
        </section>
      ))}
      {area.questions.map((x) => (
        <section key={x.question}>
          <h2>{x.question}</h2>
          <p>{x.answer}</p>
        </section>
      ))}
      <section aria-labelledby="our-take">
        <h2 id="our-take">Our take on {area.name}</h2>
        {area.ownWords.map((p) => (
          <p key={p}>{p}</p>
        ))}
      </section>
      <h2>Listings in {area.name}</h2>
      <Filters value={q} action={`/neighborhoods/${area.slug}`} fields={["price", "beds", "baths", "type", "sort"]} keep={[]} />
      <Results r={r} basePath={`/neighborhoods/${area.slug}`} searchParams={searchParams} listName={`Homes for sale in ${area.name}`} />
      {sold ? (
        <p>
          <Link href={`/neighborhoods/${area.slug}/sold`}>Recently sold homes in {area.name}</Link>
        </p>
      ) : null}
    </main>
  );
}
  1. Put the brand styles and the site-wide JSON-LD in your layout, app/layout.tsx:

app/layout.tsx

// The site shell: the recipes' stylesheet in your brand colors, your organization's JSON-LD, the
// header and footer. app/site.css lays out the page around the components in the same brand colors.
import type { ReactNode } from "react";
import Link from "next/link";
import { JsonLd, RecipesStyles } from "@ruuster/idx-recipes";
import { getMeta } from "@/lib/idx";
import { SITE_NAME, SITE_ORIGIN } from "@/lib/site";
import "./site.css";

export const metadata = {
  metadataBase: new URL(SITE_ORIGIN),
  title: SITE_NAME,
};

export default async function RootLayout({ children }: { children: ReactNode }) {
  const meta = await getMeta();
  return (
    <html lang="en">
      <head>
        <link rel="preconnect" href="https://photos.ruuster.com" />
      </head>
      <body>
        <RecipesStyles themeVars={meta.ok ? meta.data.themeVars : undefined} />
        {meta.ok && meta.data.organization?.jsonLd ? <JsonLd docs={meta.data.organization.jsonLd} /> : null}
        <div className="rw-recipes site">
        <header className="site-header">
          <div className="site-header__inner">
            <Link href="/" className="site-brand">
              {SITE_NAME}
            </Link>
            <nav aria-label="Main" className="site-nav">
              <Link href="/search">Search</Link>
              <Link href="/neighborhoods">Neighborhoods</Link>
              <Link href="/our-listings">Our listings</Link>
              <Link href="/open-houses">Open houses</Link>
              <Link href="/search" className="site-cta">
                Find a home
              </Link>
            </nav>
          </div>
        </header>
        <div className="site-main">{children}</div>
        <footer className="site-footer">
          <div className="site-footer__inner">
            <span className="site-footer__brand">{SITE_NAME}</span>
            <p>
              Equal Housing Opportunity. {SITE_NAME} follows the Fair Housing Act and does not discriminate on the basis of race, color, religion,
              sex, disability, familial status or national origin.
            </p>
          </div>
        </footer>
        </div>
      </body>
    </html>
  );
}
  1. Run npm run dev and open http://localhost:3000/neighborhoods/ followed by one of your area slugs.

Test it

  • Count the listing links in the HTML your server sent. The count should match the cards on the page, because every card is a real link:

    curl -s http://localhost:3000/neighborhoods/your-area | grep -o 'href="[^"]*/homes/[^"]*"' | sort -u | wc -l
    
  • View the page source. You should see the <title> and <link rel="canonical"> from data.head, one <script type="application/ld+json"> block, and every board's disclaimer at the bottom. The canonical link and the card links name your live domain even on localhost, because they name the page search engines should index (see Keys and domains).

  • Turn JavaScript off in your browser and reload. Every card is still there.

What you just built

  • The page calls the API from the server with the secret key, so the key never reaches the browser.
  • generateMetadata passes data.head through toMetadata, so the title, description, canonical link, robots value and Open Graph tags come from the API.
  • <JsonLd docs={r.data.jsonLd} /> prints the ItemList and BreadcrumbList documents safely.
  • ListingGrid prints each card's attribution, and MlsDisclaimers prints every board's disclaimer from r.meta.mls.
  • revalidate re-renders the page at most every five minutes, and on a 429 or 503 the page throws, so Next.js keeps serving the last good copy.

Next