Storefront
A complete store built from the HextaUI commerce blocks. Handles browsing, filters, the bag, checkout and order tracking on one shared store.
Storefront is a whole online shop for Halden, the home goods brand every commerce block uses, put together from the other blocks. The header search is Product Search, the bag is Cart, every grid and rail is Product Card, the collection page is Product Filters, the product page is Product Gallery, Variant Picker, Price, Reviews and the Delivery Estimate from Shipping Methods, checkout is Checkout, and the last two pages are Order Confirmation and Order Tracking. Storefront adds only the glue: a header and footer, routing, one shared store and small page layouts.
There are nine pages: Home with a hero, shop-by-room tiles, a New arrivals rail and an editorial band; a collection page with filters in a sidebar on wide screens and a sheet on phones, a sort and density toolbar, removable chips and Load more; a product page; search results; a wishlist; your orders; a full-page checkout with its own minimal header; the order confirmation; and order tracking. The demo catalog has 37 pieces across Living, Bedding, Kitchen and Lighting, with sales, low stock, a pre-order and sold-out items.
Everything reads from one store, so state follows the shopper. Quick add on a card, Add to bag on a product page and the bag drawer all change the same cart, and the bag count in the header rolls on every page. Hearts on cards and the product page fill the same wishlist, products you open join Recently viewed, and a placed order shows up under Your orders with its tracking. The bag shows how far you are from free shipping over $150.
Routing lives in the block. Pages are hash URLs like #/collections/living?color=Oat&sort=newest, so Back and Forward work, links open in a new tab, and the filters, sort, Load more page and chosen variant survive a reload. Going back puts you where you were scrolled. Only the page scrolls: the header stays pinned, the frame fills its container, and pages cross-fade in 150 ms, or not at all with reduced motion.
Procurez-vous HextaUI Pro
Un seul paiement débloque tous les blocs, y compris les prochains. Voir les tarifs.
Ajouter le registre Pro à components.json
components.json Ajouter votre token
Créez un token sur votre page de compte et placez-le dans
.env.localsous le nomHEXTAUI_PRO_TOKEN.Ajouter le block
pnpm dlx shadcn@latest add @hextaui-pro/storefront
Next.js App Router routes
The store routes with the URL hash by default. Pass a router built from usePathname, useSearchParams and useRouter to give every page a real URL under /shop, with filters, sort and the chosen variant in the query string.
Your own cart and wishlist API
Pass api functions that call your server. Each one runs before the shared store changes, returns the server’s cart when it has one, and anything it throws shows where the shopper acted.
Shopify Storefront API
Map addToCart, updateLine and removeLine to cartLinesAdd, cartLinesUpdate and cartLinesRemove, convert the returned cart once, and let userErrors become the message under the button or the line.
Anatomie
Les parties à composer, de l’extérieur vers l’intérieur.
| Partie | Description |
|---|---|
Storefront | The app shell: announcement bar, header with nav, search, account, wishlist and bag, the page area, footer with a newsletter field, and routing. |
createStorefrontStore, useStorefrontStore | A tiny external store holding the cart, wishlist, recently viewed products and placed orders, read with useSyncExternalStore. |
simulatedApi | The default api: waits like a real server, merges cart lines, refuses more than the stock on hand, and places orders through the Checkout demo helpers. |
useHashRouter, routeFromPath, routeToPath | The built-in hash router and the helpers to build your own adapter. |
ShopCatalog | Your products (variant-picker Product plus collection, category, material, colors, description and reviews) and the collections shown in the nav. |
shopFacets, shopAccessors, sortProducts, runSearch | Pure helpers that build facets with counts, sort a listing and search the catalog with typo tolerance. |
Storefront
Also takes div props for the root. Give it a height, such as h-svh, and it fills it.
| Prop | Type | Par défaut |
|---|---|---|
storeThe shared state, from createStorefrontStore({ cart, wishlist, recent, orders }). | StorefrontStore | – |
catalog{ products, collections, colors?, currencyCode }. Products drive every grid, facet, search result and recommendation. | ShopCatalog | – |
nameThe wordmark in the header, footer and checkout. | ReactNode | "Halden" |
navCollection ids for the header nav, in order. | string[] | every collection |
heroThe home page hero. cta is { label, to } with a route. | { image, eyebrow?, title, description?, cta? } | – |
editorialThe quiet band on the home page. | { image, eyebrow?, title, description, cta? } | – |
announcementThe thin bar above the header. null hides it. | ReactNode | null | free shipping and returns line |
apiServer calls: addToCart, updateLine, removeLine, restoreLine, setWishlisted, notifyMe, estimateDelivery, subscribe, getRates, estimateTax, applyCode, removeCode, placeOrder, express. Missing ones are simulated. Return the server’s cart to use it, or throw to show the message. | Partial<StorefrontApi> | simulatedApi() |
router{ route, navigate, href }. Replaces the built-in hash router. | StorefrontRouter | useHashRouter() |
searchYour own search for the header field, such as Algolia or Shopify predictive search. | SearchFn | searches the catalog |
trendingTrending searches shown when the search field is empty. | string[] | [] |
customerThe signed-in shopper for checkout, with saved addresses and cards. | CheckoutCustomer | null | – |
onSignIn, onSignOutShow Sign in and Sign out in checkout. | () => void | – |
checkoutexpressMethods, paymentMethods, addressForm, payment, footer, defaultCountry and labels, passed to Checkout. | Pick<CheckoutProps, …> | – |
freeShippingThresholdDrives the bag’s free shipping bar and free delivery on the product page. null hides both. | Money | null | $150 |
pageSizeProducts per Load more step on collection pages. | number | 12 |
localeLocale for money, numbers and dates. | string | "en-US" |
StorefrontRoute
What the router passes around.
| Prop | Type | Par défaut |
|---|---|---|
pageThe page. | "home" | "collection" | "product" | "search" | "wishlist" | "account" | "checkout" | "order" | "tracking" | – |
idThe collection id, product handle or order id. | string | – |
searchQuery params: filters and sort on collections, q on search, option values like glaze=Sand on products. | string | – |
createStorefrontStore
Returns a StorefrontStore with setCart, clearCart, setWishlisted, viewProduct, clearRecent and addOrder.
| Prop | Type | Par défaut |
|---|---|---|
cartThe starting cart, from your server or a cookie. | Cart | an empty USD cart |
wishlistSaved product ids. | string[] | [] |
recentRecently viewed product ids, newest first. Keeps 12. | string[] | [] |
ordersOrders shown under Your orders. | Order[] | [] |
| Touche | Action |
|---|---|
| ⌘K | Opens search from any page. / works too. |
| Tab | Moves through the header, then the page. After a page change focus starts at the top of the new page. |
| Enter | Opens a link, adds to the bag, or searches for the typed text. |
| ←→ | Choose a color or size in the variant picker, and move between gallery images. |
| Esc | Closes the bag, the menu, the filter sheet or the search dropdown. |
- Every page keeps the accessibility of the block that draws it: the bag announces changes politely, Add to bag says what was added, filters announce the result count, and the variant picker is a real radio group with sold-out sizes still focusable for Notify me.
- Links are real links with real hrefs, so they work with a middle click and in a new tab. A page change announces the new page and moves focus to its start, and Back restores your scroll position.
- Nothing important is shown only by color or motion. Sold out, low stock and sale are words, the header buttons say how many items are in the bag and the wishlist, and page fades, rails and the hero button respect reduced motion.
Construit avec
Les composants HextaUI gratuits dont Storefront est constitué. Chacun s’installe séparément.
Code
11 fichiers, ajoutés à components/blocks/storefront.