# Recipes for every page type

Source: https://help.ruuster.com/idx/recipes

> Complete, server-rendered page recipes for a real estate site on the Ruuster Listings API, each with the calls it makes, the exact steps, the full code, the rules it follows and a prompt for your AI coding assistant.

Each recipe is one page of a real estate site, built on the Ruuster Listings API and rendered on your
server, so the listings are in the HTML that search engines and AI assistants read. Every recipe has
the same parts: what the visitor sees, the calls the page makes and with which key, numbered steps,
the complete code from the examples repo, the rules the page follows, a test you can run, and a
prompt that builds it with your AI coding assistant (Claude Code, Codex, Cursor or similar).

The code comes from the examples repo's Next.js site (`examples/idx-nextjs`). Every file is
complete and type-checked, and the pages share four small files you add once:

| File | What it holds |
|---|---|
| `lib/idx.ts` | The one API client, built with your secret key, used only on the server |
| `lib/site.ts` | Your site name, origin, consent wording and the route your forms post to |
| `content/areas.ts` | Your areas, each with the row `/v1/suggest` answered for it and your own words |
| `components/results.tsx` | The cards, pagination, map, disclaimers and JSON-LD of every results page |

<p class="code-title"><code>lib/idx.ts</code></p>

```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";
```

<p class="code-title"><code>lib/site.ts</code></p>

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

## The recipes

| Recipe | URL on your site | The main call |
|---|---|---|
| [Search page with map](https://help.ruuster.com/idx/recipe-search-page) | `/search` | `GET /v1/listings` with the page's URL parameters |
| [Neighborhood and area pages](https://help.ruuster.com/idx/recipe-neighborhood-page) | `/neighborhoods/midtown` | `GET /v1/listings` and `GET /v1/market` for one stored area |
| [Listing detail page](https://help.ruuster.com/idx/recipe-listing-detail) | `/homes/123-peachtree-st-ne-atlanta-ga-30308-…` | `GET /v1/listings/{listingId}` |
| [Recently sold](https://help.ruuster.com/idx/recipe-recently-sold) | `/neighborhoods/midtown/sold` | `GET /v1/listings` with `status=closed` |
| [Our listings](https://help.ruuster.com/idx/recipe-our-listings) | `/our-listings` | `GET /v1/listings` with `ownListings=1` |
| [Open houses this weekend](https://help.ruuster.com/idx/recipe-open-houses) | `/open-houses` | `GET /v1/listings` with `openHousePeriod=this_weekend` |
| [Homepage search bar](https://help.ruuster.com/idx/recipe-search-bar) | `/` | `GET /v1/suggest` from the browser |
| [Featured listings strip](https://help.ruuster.com/idx/recipe-featured-strip) | `/` | `GET /v1/collections/{collectionId}/listings` |
| [One agent's listings](https://help.ruuster.com/idx/recipe-agent-listings) | `/agents/jordan-agent` | `GET /v1/listings` with `agent` |
| [Area guide hub](https://help.ruuster.com/idx/recipe-area-guide-hub) | `/neighborhoods` | `GET /v1/listings` per area, for the counts |
| [Price reduced](https://help.ruuster.com/idx/recipe-price-reduced) | `/price-reduced` | `GET /v1/listings` with `priceReduction=7d` |
| [New listings this week](https://help.ruuster.com/idx/recipe-new-listings) | a weekly report or post, or `/new-listings` | `GET /v1/listings` with `listedSince=7d&sort=newest` |
| [New construction](https://help.ruuster.com/idx/recipe-new-construction) | `/new-construction` | `GET /v1/listings` with `newConstruction=1` |
| [Registration, tour and contact forms](https://help.ruuster.com/idx/recipe-forms) | on your listing and agent pages | your own route to your CRM |

The listing page carries five screens of its own. Each has a page with what it shows, how it opens and
its props:

| Screen | Opens from | What it uses |
|---|---|---|
| [Photo gallery](https://help.ruuster.com/idx/recipe-gallery) | Any photo, "N photos" or "Street view" | The photos already in the listing answer |
| [Share a listing](https://help.ruuster.com/idx/recipe-share) | The share button | Your own listing URL, shared from the browser |
| [Contact the agent](https://help.ruuster.com/idx/recipe-contact-agent) | "Contact" and your agent's name | Your own route to your CRM |
| [Book a tour](https://help.ruuster.com/idx/recipe-tour-booking) | "Choose tour time" and "Schedule a tour" | Your own route to your CRM |
| [Mortgage calculator](https://help.ruuster.com/idx/recipe-mortgage-calculator) | Shown under the property details | `GET /v1/mortgage/estimate` from the browser |

The UI on every page comes from the [recipe components](https://help.ruuster.com/idx/recipe-components)
in `@ruuster/idx-recipes`. They reproduce the Ruuster listing search look, and they take your brand
colors from `GET /v1/meta` ([Match your brand](https://help.ruuster.com/idx/theming)).

<figure class="idx-shot"><img src="/idx-docs/screens/ours/listing-grid-1440.png" alt="Listing grid with the disclaimers under it, on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>The cards every results recipe renders.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/listing-grid-375.png" alt="Listing grid with the disclaimers under it, on a phone (375 px wide)" width="375" height="1403" loading="lazy" decoding="async"><figcaption>The cards every results recipe renders.</figcaption></figure>

The markup is `static/html/listing-grid.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

## Rules every recipe follows

- The page calls the API from your server with `IDX_SECRET_KEY`. No key is ever in a page: the
  search box, the filter choices and the mortgage calculator call your own listings route
  (`createListingsRoute` from `@ruuster/idx/route`), which adds the secret key on your server.
- Every location is a `where` object exactly as `/v1/suggest` returned it, stored once and never
  edited by hand.
- Every card shows the attribution its board requires, and every page with listings shows every
  board's disclaimer and the "Data last updated" line.
- Cards and pagination are plain `<a href>` links, so crawlers follow them.
- On a 429 or 503 the page throws, so Next.js keeps serving the last good page.
- Forms appear on listing pages and agent pages, and they post to your own server route, which sends
  the lead to your CRM ([Registration, tour and contact forms](https://help.ruuster.com/idx/recipe-forms)).

## Build them with AI

Every recipe ends with a prompt from the [prompt library](https://help.ruuster.com/idx/build-with-ai).
Save `RUUSTER_IDX.md` at the root of your project, add the
[starter CLAUDE.md or AGENTS.md](https://help.ruuster.com/idx/ai-starter-files), and paste the prompt.

On a site without React, such as PHP, Python, Ruby on Rails, Go or plain HTML, [Build without React: HTML, CSS and JavaScript](https://help.ruuster.com/idx/recipe-html-css) gives you the same markup, the stylesheet and the script for every widget.
