# Listing alerts sign-up for an area

Source: https://help.ruuster.com/idx/recipe-alerts-signup

> A "Get listing alerts" sign-up box for one area, such as new listings in a ZIP code or neighborhood, for your neighborhood and area pages.

On a neighborhood or area page, offer the area's new listings by email. `AlertSignupForm` with
`variant="signup"` asks for a name, an email and how often, and saves a search for that area only.

## What the visitor sees

The same form as the search page's, with a "Get listing alerts" button and no search name to fill
in: you name the search for them, such as "New listings in Travis Heights".

## The component

Pass the area as criteria: a `zip`, a `city` with `state`, or the `where` object `/v1/suggest`
returned for the neighborhood. A daily digest suits area alerts best.

<p class="code-title"><code>packages/ruuster-idx-recipes/snippets/alerts-search-page.tsx</code></p>

```tsx
// On your search page: "Email me new matches" for the search the visitor is looking at.
import { fromSearchParams } from "@ruuster/idx";
import { AlertSignupForm } from "@ruuster/idx-recipes";

const ALERTS_CONSENT = "Email me new listings that match this search. I can unsubscribe at any time.";

export function SearchAlerts({ searchParams }: { searchParams: Record<string, string | string[] | undefined> }) {
  // The page's own filters are the saved search's criteria (no page, sort or view).
  const { page: _page, sort: _sort, view: _view, limit: _limit, ...criteria } = fromSearchParams(searchParams) as Record<string, unknown>;
  return <AlertSignupForm action="/api/alerts/save-search" criteria={criteria as Record<string, string>} consentText={ALERTS_CONSENT} askName />;
}

// A sign-up box for one area's new listings, for a neighborhood page.
export function AreaAlerts({ zip, areaName }: { zip: string; areaName: string }) {
  return <AlertSignupForm variant="signup" action="/api/alerts/save-search" criteria={{ zip }} searchName={`New listings in ${areaName}`} consentText={ALERTS_CONSENT} defaultFrequency="daily" />;
}
```

It posts to the same server route as the search page's form:
[Email me new matches](/idx/recipe-save-search) has the route.

## Rules

- Keep each sign-up to one area, so the subject line and the digest stay clear.
- Your consent sentence must say what the visitor will get and that they can unsubscribe.
