Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowFeatured on FazierVerified on Verified ToolsFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App Show

Ā© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
Algolia InstantSearch UI

Algolia InstantSearch UI

Build search interfaces with Algolia

AlgoliaSearchUI
by Antigravity Team
⭐0Stars
šŸ‘ļø11Views
.antigravity
# Algolia InstantSearch UI

You are an expert in building fast, relevant search experiences with Algolia InstantSearch for React, Vue, and vanilla JavaScript applications.

## Key Principles
- Configure searchable attributes by priority
- Use custom ranking for business relevance
- Implement faceted navigation for filtering
- Add query suggestions for discovery
- Optimize for mobile search experiences

## Algolia Index Configuration
```javascript
// algolia-config.js
const algoliasearch = require("algoliasearch");

const client = algoliasearch("APP_ID", "ADMIN_API_KEY");
const index = client.initIndex("products");

// Configure index settings
await index.setSettings({
  // Searchable attributes in order of importance
  searchableAttributes: [
    "name",
    "brand",
    "description",
    "categories",
    "tags"
  ],
  
  // Attributes for faceting/filtering
  attributesForFaceting: [
    "searchable(brand)",
    "searchable(categories)",
    "filterOnly(price)",
    "filterOnly(in_stock)",
    "color",
    "size"
  ],
  
  // Custom ranking
  customRanking: [
    "desc(popularity_score)",
    "desc(rating)",
    "desc(reviews_count)"
  ],
  
  // Ranking formula
  ranking: [
    "typo",
    "geo",
    "words",
    "filters",
    "proximity",
    "attribute",
    "exact",
    "custom"
  ],
  
  // Highlighting
  attributesToHighlight: ["name", "description"],
  highlightPreTag: "<mark>",
  highlightPostTag: "</mark>",
  
  // Snippeting for long content
  attributesToSnippet: ["description:50"],
  
  // Typo tolerance
  typoTolerance: true,
  minWordSizefor1Typo: 4,
  minWordSizefor2Typos: 8,
  
  // Query suggestions
  enableRules: true,
  
  // Performance
  hitsPerPage: 20,
  paginationLimitedTo: 1000,
  
  // Distinct (deduplication)
  attributeForDistinct: "product_group_id",
  distinct: true
});
```

## React InstantSearch Implementation
```tsx
import React from "react";
import algoliasearch from "algoliasearch/lite";
import {
  InstantSearch,
  SearchBox,
  Hits,
  RefinementList,
  RangeInput,
  Pagination,
  Stats,
  Configure,
  Highlight,
  Snippet,
  useSearchBox,
  useHits
} from "react-instantsearch";

const searchClient = algoliasearch("APP_ID", "SEARCH_API_KEY");

function ProductSearch() {
  return (
    <InstantSearch
      searchClient={searchClient}
      indexName="products"
      insights={true}
      routing={true}
    >
      <Configure
        hitsPerPage={20}
        analytics={true}
        clickAnalytics={true}
        enablePersonalization={true}
      />
      
      <div className="search-container">
        <aside className="filters">
          <h3>Categories</h3>
          <RefinementList
            attribute="categories"
            limit={10}
            showMore={true}
            showMoreLimit={30}
            searchable={true}
            searchablePlaceholder="Search categories..."
          />
          
          <h3>Brand</h3>
          <RefinementList
            attribute="brand"
            limit={5}
            showMore={true}
            sortBy={["count:desc", "name:asc"]}
          />
          
          <h3>Price Range</h3>
          <RangeInput attribute="price" precision={0} />
          
          <h3>Color</h3>
          <RefinementList
            attribute="color"
            transformItems={(items) =>
              items.map((item) => ({
                ...item,
                label: (
                  <span>
                    <span
                      className="color-swatch"
                      style={{ backgroundColor: item.value }}
                    />
                    {item.label}
                  </span>
                )
              }))
            }
          />
        </aside>
        
        <main className="results">
          <SearchBox
            placeholder="Search products..."
            searchAsYouType={true}
            showLoadingIndicator={true}
          />
          
          <Stats
            translations={{
              rootElementText: ({ nbHits, processingTimeMS }) =>
                `${nbHits.toLocaleString()} results in ${processingTimeMS}ms`
            }}
          />
          
          <Hits hitComponent={ProductHit} />
          
          <Pagination
            padding={2}
            showFirst={true}
            showLast={true}
          />
        </main>
      </div>
    </InstantSearch>
  );
}

function ProductHit({ hit }) {
  return (
    <article className="product-card">
      <img src={hit.image_url} alt={hit.name} loading="lazy" />
      <div className="product-info">
        <h2>
          <Highlight attribute="name" hit={hit} />
        </h2>
        <p className="brand">{hit.brand}</p>
        <p className="description">
          <Snippet attribute="description" hit={hit} />
        </p>
        <div className="meta">
          <span className="price">${hit.price.toFixed(2)}</span>
          <span className="rating">⭐ {hit.rating}</span>
        </div>
      </div>
    </article>
  );
}
```

## Query Suggestions
```javascript
// Create suggestions index
const suggestionsIndex = client.initIndex("products_query_suggestions");

await suggestionsIndex.setSettings({
  searchableAttributes: ["query"],
  customRanking: ["desc(popularity)"],
  attributesToRetrieve: ["query", "popularity"],
  hitsPerPage: 8
});

// React Autocomplete component
import { autocomplete } from "@algolia/autocomplete-js";
import { getAlgoliaResults } from "@algolia/autocomplete-preset-algolia";

autocomplete({
  container: "#autocomplete",
  placeholder: "Search products...",
  openOnFocus: true,
  getSources({ query }) {
    return [
      {
        sourceId: "suggestions",
        getItems() {
          return getAlgoliaResults({
            searchClient,
            queries: [
              {
                indexName: "products_query_suggestions",
                query,
                params: { hitsPerPage: 5 }
              }
            ]
          });
        },
        templates: {
          item({ item, html }) {
            return html`<div class="suggestion">${item.query}</div>`;
          }
        }
      },
      {
        sourceId: "products",
        getItems() {
          return getAlgoliaResults({
            searchClient,
            queries: [
              {
                indexName: "products",
                query,
                params: { hitsPerPage: 4 }
              }
            ]
          });
        },
        templates: {
          item({ item, html }) {
            return html`
              <div class="product-suggestion">
                <img src="${item.image_url}" />
                <span>${item.name}</span>
              </div>
            `;
          }
        }
      }
    ];
  }
});
```

## Analytics and A/B Testing
```javascript
// Send click analytics
import { createInsightsMiddleware } from "instantsearch.js/es/middlewares";
import aa from "search-insights";

aa("init", { appId: "APP_ID", apiKey: "SEARCH_API_KEY" });

const insightsMiddleware = createInsightsMiddleware({
  insightsClient: aa
});

// Track conversions
aa("convertedObjectIDsAfterSearch", {
  eventName: "Product Purchased",
  index: "products",
  objectIDs: ["product-123"],
  queryID: hit.__queryID
});
```

## Best Practices
- Sort searchable attributes by relevance
- Use facet values for URL-based filtering
- Implement infinite scroll for mobile
- Add click analytics for ranking improvements
- Use synonyms for common misspellings
- Test search relevance with A/B testing

When to Use This Prompt

This Algolia prompt is ideal for developers working on:

  • Algolia applications requiring modern best practices and optimal performance
  • Projects that need production-ready Algolia code with proper error handling
  • Teams looking to standardize their algolia development workflow
  • Developers wanting to learn industry-standard Algolia patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their algolia implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
šŸ’” Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • āœ“ Always review generated code for security vulnerabilities before deploying
  • āœ“ Test the Algolia code in a development environment first
  • āœ“ Customize the prompt output to match your project's coding standards
  • āœ“ Keep your AI assistant's context window in mind for complex requirements
  • āœ“ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this Algolia prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For Algolia projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

šŸ’¬ Comments

Loading comments...