Menu · Recipes
Recipes

Recently sold

A /neighborhoods/<area>/sold page listing homes sold in the last 6 months, published only where your boards show sold data, with a link to the area page everywhere else.

View as Markdownopenapi.json

A page such as /neighborhoods/midtown/sold with the homes that sold in the area in the last 6 months, most recent first. Each card shows the sold price and the sold date. MLS boards decide whether sold listings may be shown, so the page first reads GET /v1/meta and publishes sold listings only when at least one of your boards allows them; on other boards it shows a link to the area page. Title it "Recently sold homes in" the area, never "our sales": the list holds every brokerage's sales.

What the visitor sees

Live preview
Sold homes use the same card, with the sold price and date.
<!--
  Listing card for a sold home (close price and close date).
  From the React component ListingCard. Generated by npm run idx:recipes-static from @ruuster/idx-recipes. Do not edit it by hand.

  Fill each value from:
  article.rw-card[data-listing-id]: listing.id
  article.rw-card[data-status]: listing.status
  .rw-card__photo[src]: listing.photos[0].url
  .rw-card__photo[srcset]: listing.photos[0].url with ?width=480, ?width=800 and ?width=1200 (photos.ruuster.com only; leave srcset and sizes out for photos on other hosts)
  .rw-card__photo[width] and [height]: listing.photos[0].width and listing.photos[0].height (800 and 600 when missing)
  .rw-card__photo[alt]: listing.photos[0].alt, else the listing name (the address, or "Home in {address.city}" when address.hidden is true)
  .rw-card__photo[loading] and [fetchpriority]: loading="eager" and fetchpriority="high" on the first card of the page only; loading="lazy" and no fetchpriority on every other card
  .rw-card__gallery[data-rw-photos]: listing.photos as JSON (url, width, height, alt of each photo), only when there are two or more photos
  .rw-card__gallery[data-rw-photo-alt]: the listing name, used for a photo with no alt; only when there are two or more photos
  .rw-card__arrow, .rw-card__dots: only when listing.photos has two or more photos; one .rw-card__dot per photo, up to five, the first with rw-card__dot--on
  .rw-card__nophoto: in place of the photo when listing.photos is empty
  .rw-card__badge: one pill: "Sold {listing.closeDate as Sep 1, 2026}" when listing.status is closed; else "Open {listing.openHouses[0], short form}" when listing.badges has open_house; else listing.badges[0].kind as New, Back on market, Price change or Coming soon. The modifier class is rw-card__badge--{kind}. Leave the pill out when none applies
  .rw-card__price: listing.closePrice when listing.status is closed, else listing.price, as fmt.usd ($480,000); leave the line out when there is no price
  .rw-card__facts li: listing.beds ("6 beds", "1 bed"), listing.baths ("5 baths"), listing.sqft ("6,838 sq ft"); leave out a fact that is missing or 0
  .rw-card__link[href]: listing.href
  .rw-card__link text: listing.address: street and unit, then city, state and ZIP; when listing.address.hidden is true, only city, state and ZIP
  .rw-card__attribution: listing.attribution.line, when the listing's board (the meta.mls entry whose mlsId is listing.mls.id) lists listing_office, listing_agent or agent_contact with placement card in required
  .rw-card__courtesy: listing.attribution.courtesy, when the board lists courtesy_line with placement card
  .rw-card__logo: the board's logo (url, width, height, alt), when the board lists mls_logo with placement card
  Every data-rw-* attribute is a hook for ruuster-idx.js; see ../HOOKS.md.
-->
<article class="rw-recipes rw-card" data-listing-id="0b6c3b52-7f0c-4a3e-9a51-6f0e2d1a0004" data-status="closed">
  <div class="rw-card__gallery" data-rw-gallery="card">
    <img class="rw-card__photo" src="https://photos.ruuster.com/l/4/0.jpg" width="1200" height="800" alt="Ranch house with a front porch" loading="lazy" decoding="async" srcSet="https://photos.ruuster.com/l/4/0.jpg?width=480 480w, https://photos.ruuster.com/l/4/0.jpg?width=800 800w, https://photos.ruuster.com/l/4/0.jpg?width=1200 1200w" sizes="(min-width: 1600px) 25vw, (min-width: 1280px) 33vw, (min-width: 602px) 50vw, 100vw" data-rw-gallery-photo=""/>
  </div>
  <span class="rw-card__badge rw-card__badge--sold">Sold Sep 1, 2026</span>
  <div class="rw-card__band">
    <p class="rw-card__price">$418,500</p>
    <ul class="rw-card__facts">
      <li class="rw-fact"><svg class="rw-icon rw-fact__icon" viewBox="0 0 22 22" width="18" height="18" data-rw-icon="beds" focusable="false" aria-hidden="true"><g fill="none"><path d="M10.4 10.0448V7.52239H9.00002C8.22881 7.52239 7.71077 7.52363 7.32434 7.57403C6.95517 7.62218 6.79717 7.7054 6.69292 7.80654C6.58866 7.90768 6.50288 8.06096 6.45325 8.41911C6.4013 8.79401 6.40002 9.29659 6.40002 10.0448L10.4 10.0448Z" fill="currentColor"/><path d="M15.6 10.0448C15.6 9.29659 15.5987 8.79401 15.5468 8.41911C15.4972 8.06096 15.4114 7.90768 15.3071 7.80654C15.2029 7.7054 15.0449 7.62218 14.6757 7.57403C14.2893 7.52363 13.7712 7.52239 13 7.52239H11.6V10.0448L15.6 10.0448Z" fill="currentColor"/><path fill-rule="evenodd" clip-rule="evenodd" d="M11.8 5H10.2C7.18303 5 5.67454 5 4.73728 5.90928C3.9193 6.70284 3.8152 7.9185 3.80195 10.1607V11.4158C3.49768 11.5857 3.2576 11.8491 3.12179 12.1672C3 12.4524 3 12.8141 3 13.5373C3 14.2606 3 14.6222 3.12179 14.9074C3.28418 15.2878 3.59566 15.59 3.98771 15.7475C4.18962 15.8287 4.42864 15.8541 4.8 15.862V17.4179C4.8 17.7394 5.06863 18 5.4 18C5.73137 18 6 17.7394 6 17.4179V15.8657H16V17.4179C16 17.7394 16.2686 18 16.6 18C16.9314 18 17.2 17.7394 17.2 17.4179V15.862C17.5714 15.8541 17.8104 15.8287 18.0123 15.7475C18.4043 15.59 18.7158 15.2878 18.8782 14.9074C19 14.6222 19 14.2606 19 13.5373C19 12.8141 19 12.4524 18.8782 12.1672C18.7424 11.8491 18.5023 11.5857 18.1981 11.4158V10.1607C18.1848 7.9185 18.0807 6.70284 17.2628 5.90928C16.3255 5 14.817 5 11.8 5ZM16.8 11.2091V10.0044C16.8 9.30712 16.8001 8.72559 16.7361 8.26399C16.6686 7.77674 16.52 7.33684 16.1557 6.98334C15.7913 6.62984 15.3378 6.48574 14.8356 6.42023C14.3598 6.35817 13.7604 6.35819 13.0416 6.35821H8.95842C8.23964 6.35819 7.64026 6.35817 7.16444 6.42023C6.6622 6.48574 6.20876 6.62984 5.84439 6.98334C5.48001 7.33684 5.33148 7.77674 5.26395 8.26399C5.19998 8.72561 5.2 9.30709 5.20002 10.0044V11.2091C5.26357 11.209 5.33015 11.209 5.4 11.209H16.6C16.6699 11.209 16.7365 11.209 16.8 11.2091Z" fill="currentColor"/></g></svg>4 beds</li>
      <li class="rw-fact"><svg class="rw-icon rw-fact__icon" viewBox="0 0 22 22" width="18" height="18" data-rw-icon="bath" focusable="false" aria-hidden="true"><g fill="none"><path d="M4.86047 5.33311C4.86047 4.66106 5.40528 4.11626 6.07733 4.11626C6.57491 4.11626 7.02237 4.4192 7.20716 4.88118L7.31379 5.14774C6.87136 5.47013 6.5099 5.91966 6.28724 6.46795C5.97445 7.23818 5.99132 8.06533 6.27278 8.77964C6.32816 8.92017 6.43812 9.03225 6.57756 9.0903C6.71701 9.14835 6.87403 9.1474 7.01276 9.08768L11.4487 7.17806C11.7256 7.05886 11.8578 6.7413 11.7473 6.46081C11.4657 5.74622 10.9159 5.13719 10.1603 4.8144C9.55652 4.55646 8.91592 4.52175 8.32557 4.67152L8.2436 4.46661C7.88928 3.58083 7.03137 3 6.07733 3C4.78877 3 3.74419 4.04457 3.74419 5.33311V10.4417H3.55814C3.24989 10.4417 3 10.6916 3 10.9999C3 11.3081 3.24989 11.558 3.55814 11.558H3.74419V11.7441C3.74419 11.7469 3.74421 11.7497 3.74425 11.7525C3.74418 11.7663 3.74418 11.7801 3.74419 11.7937L3.74419 11.8219C3.74419 12.1011 3.74419 12.2648 3.75577 12.4474C3.8614 14.1117 4.76078 15.6486 6.06424 16.6535C6.05401 16.6696 6.04451 16.6864 6.03579 16.7038L5.2916 18.1921C5.15375 18.4678 5.2655 18.8031 5.54121 18.941C5.81692 19.0788 6.15218 18.9671 6.29004 18.6914L7.0102 17.251C7.60683 17.553 8.25567 17.7518 8.9305 17.8201C9.11241 17.8385 9.22344 17.8427 9.41256 17.8498L9.41763 17.85C9.9685 17.8707 10.5077 17.8835 11 17.8835C11.4923 17.8835 12.0315 17.8707 12.5824 17.85L12.5874 17.8498C12.7765 17.8427 12.8876 17.8385 13.0695 17.8201C13.7444 17.7518 14.3933 17.553 14.99 17.251L15.7102 18.6914C15.8481 18.9671 16.1833 19.0788 16.459 18.941C16.7347 18.8031 16.8465 18.4678 16.7086 18.1921L15.9645 16.7038C15.9557 16.6863 15.9462 16.6695 15.9359 16.6534C17.2393 15.6485 18.1386 14.1117 18.2442 12.4474C18.2558 12.2649 18.2558 12.1012 18.2558 11.8219L18.2558 11.7937C18.2559 11.749 18.2559 11.7025 18.2531 11.6596C18.2509 11.6253 18.2473 11.5915 18.2425 11.558H18.4419C18.7501 11.558 19 11.3081 19 10.9999C19 10.6916 18.7501 10.4417 18.4419 10.4417H4.86047V5.33311Z" fill="currentColor"/></g></svg>3 baths</li>
      <li class="rw-fact"><svg class="rw-icon rw-fact__icon" viewBox="0 0 22 22" width="18" height="18" data-rw-icon="square" focusable="false" aria-hidden="true"><g fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.02513 5.02513C4 6.05025 4 7.70017 4 11C4 14.2998 4 15.9497 5.02513 16.9749C6.05025 18 7.70017 18 11 18C14.2998 18 15.9497 18 16.9749 16.9749C18 15.9497 18 14.2998 18 11C18 7.70017 18 6.05025 16.9749 5.02513C15.9497 4 14.2998 4 11 4C7.70017 4 6.05025 4 5.02513 5.02513ZM10.1232 6.79555C10.1256 7.08549 9.89256 7.32252 9.60263 7.32498C9.00351 7.33006 8.58507 7.34985 8.27026 7.41152C7.9701 7.47031 7.80396 7.55998 7.68197 7.68197C7.55998 7.80396 7.47031 7.9701 7.41152 8.27026C7.34985 8.58507 7.33006 9.00351 7.32498 9.60263C7.32252 9.89256 7.08549 10.1256 6.79555 10.1232C6.50561 10.1207 6.27256 9.88366 6.27502 9.59372C6.28007 8.99824 6.2985 8.49011 6.3811 8.06842C6.46657 7.63208 6.62721 7.2518 6.93951 6.93951C7.2518 6.62721 7.63208 6.46657 8.06842 6.3811C8.49011 6.2985 8.99824 6.28007 9.59372 6.27502C9.88366 6.27256 10.1207 6.50561 10.1232 6.79555ZM11.8751 6.79555C11.8776 6.50561 12.1146 6.27256 12.4046 6.27502C13 6.28007 13.5082 6.2985 13.9299 6.3811C14.3662 6.46657 14.7465 6.62721 15.0588 6.93951C15.3711 7.2518 15.5317 7.63208 15.6172 8.06842C15.6998 8.49011 15.7182 8.99824 15.7233 9.59372C15.7257 9.88366 15.4927 10.1207 15.2027 10.1232C14.9128 10.1256 14.6758 9.89256 14.6733 9.60263C14.6682 9.00351 14.6484 8.58507 14.5868 8.27026C14.528 7.9701 14.4383 7.80396 14.3163 7.68197C14.1943 7.55998 14.0282 7.47031 13.728 7.41152C13.4132 7.34985 12.9948 7.33006 12.3957 7.32498C12.1057 7.32252 11.8727 7.08549 11.8751 6.79555ZM7.32498 12.396C7.32252 12.1061 7.08549 11.873 6.79555 11.8755C6.50561 11.8779 6.27256 12.115 6.27502 12.4049C6.28007 13.0004 6.2985 13.5085 6.3811 13.9302C6.46657 14.3666 6.62721 14.7468 6.93951 15.0591C7.2518 15.3714 7.63208 15.5321 8.06842 15.6175C8.49011 15.7001 8.99824 15.7186 9.59372 15.7236C9.88366 15.7261 10.1207 15.493 10.1232 15.2031C10.1256 14.9131 9.89256 14.6761 9.60263 14.6737C9.00351 14.6686 8.58507 14.6488 8.27026 14.5871C7.9701 14.5283 7.80396 14.4387 7.68197 14.3167C7.55998 14.1947 7.47031 14.0285 7.41152 13.7284C7.34985 13.4136 7.33006 12.9951 7.32498 12.396ZM15.2027 11.8755C15.4927 11.8779 15.7257 12.115 15.7233 12.4049C15.7182 13.0004 15.6998 13.5085 15.6172 13.9302C15.5317 14.3666 15.3711 14.7468 15.0588 15.0591C14.7465 15.3714 14.3662 15.5321 13.9299 15.6175C13.5082 15.7001 13 15.7186 12.4046 15.7236C12.1146 15.7261 11.8776 15.493 11.8751 15.2031C11.8727 14.9131 12.1057 14.6761 12.3957 14.6737C12.9948 14.6686 13.4132 14.6488 13.728 14.5871C14.0282 14.5283 14.1943 14.4387 14.3163 14.3167C14.4383 14.1947 14.528 14.0285 14.5868 13.7284C14.6484 13.4136 14.6682 12.9951 14.6733 12.396C14.6758 12.1061 14.9128 11.873 15.2027 11.8755Z" fill="currentColor"/></g></svg>2,410 sq ft</li>
    </ul>
    <h3 class="rw-card__address">
      <a class="rw-card__link" href="/homes/212-dogwood-ln-powder-springs-ga-30127-0b6c3b52-7f0c-4a3e-9a51-6f0e2d1a0004">212 Dogwood Ln, Powder Springs, GA 30127</a>
    </h3>
  </div>
</article>

What the page calls

When Request Key Cached
Each page view GET /v1/meta, for capabilities.sold secret key, on your server 5 minutes by Next.js
Each page view, where sold data is shown GET /v1/listings with status=closed, soldPeriod=6m, sort=close_date_desc secret key, on your server 5 minutes by Next.js
curl -s "https://idx.ruuster.com/v1/meta" \
  -H "Authorization: Bearer $IDX_SECRET_KEY"

capabilities.sold lists each board with mlsId, allowed and its sold window in days. To say which boards show sold data, match each mlsId with a board's id in data.mls, which holds its name (Sold listings shows the code).

Each sold card shows the sold price (closePrice) and a "Sold" badge with the sale date, such as "Sold Sep 1, 2026", in place of any open house.

curl -s -G "https://idx.ruuster.com/v1/listings" \
  --data-urlencode 'where={"label":"Atlanta, GA Midtown","value":"a0000000-0000-4000-8000-000000000001","source":"neighborhood","data":{"state":"GA"}}' \
  --data-urlencode status=closed \
  --data-urlencode soldPeriod=6m \
  --data-urlencode sort=close_date_desc \
  --data-urlencode limit=24 \
  --data-urlencode pageHref=/neighborhoods/midtown/sold \
  -H "Authorization: Bearer $IDX_SECRET_KEY"

Steps

  1. Build the area page first; the sold page reuses its content/areas.ts and lib/area-query.ts.
  2. Set soldPage: true on each area in content/areas.ts that should have a sold page.
  3. Create app/neighborhoods/[area]/sold/page.tsx with the code below.
  4. Open http://localhost:3000/neighborhoods/midtown/sold. On boards without sold data you see the link to the area page instead.
  5. app/sitemap.ts lists each sold page only while your boards show sold data.

The code

app/neighborhoods/[area]/sold/page.tsx

// /neighborhoods/<area>/sold: homes sold in the last 6 months. Published only when at least one of
// your boards shows sold data (GET /v1/meta capabilities.sold); otherwise it links to the area page.
import Link from "next/link";
import { notFound } from "next/navigation";
import { Results } from "@/components/results";
import { AREAS, areaBySlug } from "@/content/areas";
import { getMeta, idx } from "@/lib/idx";
import { showsSoldData, soldQuery } 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.filter((a) => a.soldPage).map((a) => ({ area: a.slug }));
}

async function soldAllowed(): Promise<boolean> {
  const meta = await getMeta();
  return meta.ok && showsSoldData(meta.data.capabilities);
}

export async function generateMetadata({ params, searchParams }: Props) {
  const area = areaBySlug(params.area);
  if (!area?.soldPage) return {};
  if (!(await soldAllowed())) return { title: `Homes in ${area.name}`, robots: "noindex,follow" };
  const r = await idx.search(soldQuery(area, searchParams));
  return r.ok ? resultsMetadata(r.data.head, `Recently sold homes in ${area.name}`) : {};
}

export default async function SoldPage({ params, searchParams }: Props) {
  const area = areaBySlug(params.area);
  if (!area?.soldPage) notFound();
  if (!(await soldAllowed())) {
    return (
      <main>
        <h1>{`Homes in ${area.name}`}</h1>
        <p>
          <Link href={`/neighborhoods/${area.slug}`}>See the homes for sale in {area.name}</Link>
        </p>
      </main>
    );
  }
  const r = await idx.search(soldQuery(area, searchParams));
  if (!r.ok) {
    const action = failureAction(r);
    if (action === "not_found") notFound();
    throw new Error(`Listings API ${r.status} ${r.error.code}`);
  }
  return (
    <main>
      <nav aria-label="Breadcrumb">
        <Link href="/neighborhoods">Neighborhoods</Link> › <Link href={`/neighborhoods/${area.slug}`}>{area.name}</Link> › Recently sold
      </nav>
      <h1>{`Recently sold homes in ${area.name}`}</h1>
      <p>Homes that sold in the last 6 months, most recent first. Each card shows the sold price and date.</p>
      <Results r={r} basePath={`/neighborhoods/${area.slug}/sold`} searchParams={searchParams} listName={`Recently sold in ${area.name}`} />
    </main>
  );
}

The sold search and the capability check, from lib/area-query.ts:

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);
}

Forms and your CRM

Sold pages carry no forms. Visitors reach your tour and contact forms from your listing pages (Registration, tour and contact forms).

Rules this page follows

MUST

  • Check capabilities.sold before showing sold listings, and follow each board's sold window (the API answers only the listings inside it).
  • Show the sold price and date on each card and every board's disclaimer under the list.

NEVER

  • Call the page "our sales" or imply your brokerage sold every home on it.
  • Fill the page with active listings when sold data is not shown, without saying so.

Test it

curl -s http://localhost:3000/neighborhoods/midtown/sold | grep -o "<h1>[^<]*</h1>"

Where your boards show sold data, the heading is "Recently sold homes in Midtown" and view source shows the cards with their sold prices. Where they do not, the page shows the link to the area page.

Build it with AI

Prompt
Read RUUSTER_IDX.md first and follow its MUST and NEVER rules. Ask me if it doesn't cover something.

Add a recently sold page at /neighborhoods/[area]/sold for each area page, following <https://help.ruuster.com/idx/recipe-recently-sold>. First read GET /v1/meta and check capabilities.sold: build the page only where at least one of my boards shows sold data, and otherwise show a link to the area page instead of sold listings. Search with status=closed, soldPeriod=6m and sort=close_date_desc, and title the page "Recently sold homes in" the area. Never fall back to active listings without saying so. Each card shows the sold price and date.

Use these environment variables: IDX_SECRET_KEY (server only), SITE_ORIGIN and SITE_NAME. Never paste a secret key into a chat, and never put IDX_SECRET_KEY in browser code, a URL or a log. No key goes in any page: my pages call my own /api/idx route, made with createListingsRoute from @ruuster/idx/route, which adds my secret key on the server (on a site with no server, the widgets call the API with no key from my approved website address).

Fair housing: describe homes, places and amenities only. Never describe the people who live in an area or who a home or area suits, and never rank schools as a reason to buy.

When you are done, tell me which of my boards show sold data according to /v1/meta.

On a site without React, such as PHP, Python, Ruby on Rails, Go or plain HTML, Build without React: HTML, CSS and JavaScript gives you the same markup, the stylesheet and the script for every widget.