Search & Filters
Search products by keyword, category, brand, and price range.
Updated
On this page
Text Search
Search products by name using the search parameter:
import dash from "@/lib/dash"
const { products } = await dash.products.list({
search: "blue dream",
})
Category Filter
Filter products by category slug:
const { products } = await dash.products.list({
category: "edibles",
})
Brand Filter
const { products } = await dash.products.list({
brand: "premium-farms",
})
Custom Field Filters
Filter by any custom field defined on your products:
const { products } = await dash.products.list({
customFields: {
featured: "true",
potency: "high",
},
})
On the REST API, custom fields are passed as query parameters prefixed with cf_:
GET /storefront/products?cf_featured=true&cf_potency=high
X-API-Key: pk_live_your_key
Combining Filters
All filters can be combined:
const { products, pagination } = await dash.products.list({
category: "flower",
search: "dream",
customFields: { featured: "true" },
limit: 12,
offset: 0,
})
Building a Search Page
"use client"
import { useState } from "react"
import dash from "@/lib/dash"
export function ProductSearch() {
const [query, setQuery] = useState("")
const [results, setResults] = useState([])
async function handleSearch(e) {
e.preventDefault()
const { products } = await dash.products.list({ search: query })
setResults(products)
}
return (
<form onSubmit={handleSearch}>
<input value={query} onChange={e => setQuery(e.target.value)}
placeholder="Search products..." />
<button type="submit">Search</button>
{results.map(p => <ProductCard key={p.id} product={p} />)}
</form>
)
}
For a complete search implementation, see the Add Search recipe.
Sorting
Sort results using the sort query parameter on the REST API:
GET /storefront/products?sort=price_asc # Cheapest first
GET /storefront/products?sort=price_desc # Most expensive first
GET /storefront/products?sort=rating # Highest rated first
GET /storefront/products?sort=newest # Most recently added
Next Steps
- List Products — Full parameter reference
- List Categories — Get categories for filter UI
- Recipe: Add Search — Full search implementation