DashForDevsDocs
DocsNewsAPI v1
dashfordevs.comSign in

© 2026 DashForDevs

DocsNewsdashfordevs.comLegalStatus
DocsRecipesAdd Search
Introduction
Getting Started
Authentication
Products
Categories
Cart
Checkout
Blog
Reviews
Webhooks
Customers
Orders
Inventory
Shipping
Discounts
Affiliates
Email
Media & Files
Analytics & Tracking
Locations
Tax
Global Data
SEO
Error Handling
Geography
Finance
Automations
Page Types
Surveys
Billing & Subscriptions
Storefront Payments
SDK Reference
REST API
Storefront Architecture
Notifications
Security
Team & Permissions
Migrations & Import
Calendar & Appointments
Contact Forms
AI Bots
Dashboard API
Deployment
Changelog
Troubleshooting
Recipes
Build a Product PageBuild a Cart DrawerBuild a Checkout FlowAdd SearchBuild a BlogAffiliate Landing PageCustomer Account PageWholesale Storefront
CLI & Deployment
Image Pipeline
White-label Platforms
Records Engine
Platform Modules
Platform Security
Site Keys & Client Sites
Use Cases
Operations

Add Search

Implement product search with filters.

Updated March 29, 2026

On this page
  • Add Search to Your Store
  • Related

Add Search to Your Store

typescript
"use client"
import { useState, useCallback } from "react"
import dash from "@/lib/dash"

export function SearchBar() {
  const [query, setQuery] = useState("")
  const [results, setResults] = useState([])
  const [loading, setLoading] = useState(false)

  const search = useCallback(async (q: string) => {
    if (q.length < 2) { setResults([]); return }
    setLoading(true)
    const { products } = await dash.products.list({ search: q, limit: 8 })
    setResults(products)
    setLoading(false)
  }, [])

  return (
    <div className="relative">
      <input value={query} onChange={e => { setQuery(e.target.value); search(e.target.value) }}
             placeholder="Search products..." className="w-full p-3 rounded bg-gray-800" />
      {results.length > 0 && (
        <div className="absolute top-full w-full bg-gray-900 border rounded mt-1 max-h-80 overflow-y-auto">
          {results.map(p => (
            <a key={p.id} href={`/products/${p.slug}`} className="flex gap-3 p-3 hover:bg-gray-800">
              <img src={p.main_image} alt="" className="w-12 h-12 rounded" />
              <div>
                <p className="font-medium">{p.name}</p>
                <p className="text-sm text-gray-400">${p.discounted_price || p.price}</p>
              </div>
            </a>
          ))}
        </div>
      )}
    </div>
  )
}

Related

  • Search & Filters
  • List Products
PreviousBuild a Checkout FlowNextBuild a Blog

On this page

  • Add Search to Your Store
  • Related