Menu · Build with AI
Build with AI

Prompt: homepage search bar

A homepage search bar that suggests places as the visitor types and hands off to your search page.

View as Markdownopenapi.json

This prompt builds the homepage search bar, which asks your own listings route for suggestions, so the page carries no key.

The prompt

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

Add a search bar to the homepage of my site that hands off to my search page, following <https://help.ruuster.com/idx/recipe-search-bar>. Use the SearchBox component with baseUrl="/api/idx" and action="/search", and add the route app/api/idx/[...path]/route.ts with `export const GET = createListingsRoute({ basePath: "/api/idx" });` if it is not there yet. It suggests places after three characters, and picking one goes to /search with the place's where object in the URL. The search page renders that search on the server with my secret key.

Use this environment variable: IDX_SECRET_KEY (server only). Never paste a secret key into a chat. 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).

When you are done, tell me how to test it with the keyboard only.

What it builds

  • your listings route, app/api/idx/[...path]/route.ts, from createListingsRoute in @ruuster/idx/route
  • the SearchBox on your homepage with action="/search" and baseUrl="/api/idx", and no key
  • the search page reading the picked place's where object from the URL

How to check it

  1. Use the keyboard only: Tab to the box, type three letters, press the down arrow and Enter.
  2. In the browser's network panel, the suggest request goes to /api/idx/suggest and carries no key.
  3. View the page source and search for idx_. Nothing is found.

On a site builder with no server of its own, use the plain HTML search box with no key instead.

Before you paste it

Follow the setup on Build it with your AI coding assistant once: RUUSTER_IDX.md at the root of your project, the two lines in CLAUDE.md or AGENTS.md, and your secret key in .env.local. Never paste a secret key into a chat. Replace the text in square brackets with your own before you send the prompt.