@thorprovider/create-storefront 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +119 -0
  2. package/bin/install.js +116 -0
  3. package/commands/sf-add-view.md +21 -0
  4. package/commands/sf-init.md +16 -0
  5. package/commands/sf-theme.md +15 -0
  6. package/commands/sf-view.md +20 -0
  7. package/package.json +40 -0
  8. package/recipes/archetype.schema.json +39 -0
  9. package/recipes/archetypes.json +148 -0
  10. package/recipes/recipe.schema.json +59 -0
  11. package/recipes/recipes.json +90 -0
  12. package/recipes/sections.json +46 -0
  13. package/recipes/validate.mjs +190 -0
  14. package/skills/building-storefronts/SKILL.md +178 -0
  15. package/skills/building-storefronts/references/frontend-integration.md +229 -0
  16. package/skills/json-render-core/SKILL.md +291 -0
  17. package/skills/json-render-next/SKILL.md +194 -0
  18. package/skills/json-render-react/SKILL.md +298 -0
  19. package/skills/json-render-remotion/SKILL.md +111 -0
  20. package/skills/json-render-shadcn/SKILL.md +159 -0
  21. package/skills/json-render-solid/SKILL.md +204 -0
  22. package/skills/nextjs-shadcn/SKILL.md +303 -0
  23. package/skills/nextjs-shadcn/references/architecture.md +499 -0
  24. package/skills/nextjs-shadcn/references/project-setup.md +127 -0
  25. package/skills/nextjs-shadcn/references/shadcn-platform.md +258 -0
  26. package/skills/nextjs-shadcn/references/sidebar.md +274 -0
  27. package/skills/nextjs-shadcn/references/styling.md +555 -0
  28. package/skills/sf-scaffold/SKILL.md +118 -0
  29. package/skills/sf-theme-gen/SKILL.md +44 -0
  30. package/skills/sf-view-gen/SKILL.md +94 -0
  31. package/skills/shadcn-component-discovery/SKILL.md +273 -0
  32. package/skills/shadcn-component-discovery/references/registries.md +226 -0
  33. package/skills/shadcn-theming/SKILL.md +104 -0
  34. package/skills/shadcn-theming/references/templates/theme-setup.md +109 -0
  35. package/skills/shadcn-theming/references/theming-guide.md +90 -0
  36. package/skills/storefront-best-practices/SKILL.md +421 -0
  37. package/skills/storefront-best-practices/reference/components/breadcrumbs.md +123 -0
  38. package/skills/storefront-best-practices/reference/components/cart-popup.md +189 -0
  39. package/skills/storefront-best-practices/reference/components/country-selector.md +298 -0
  40. package/skills/storefront-best-practices/reference/components/footer.md +112 -0
  41. package/skills/storefront-best-practices/reference/components/hero.md +241 -0
  42. package/skills/storefront-best-practices/reference/components/megamenu.md +239 -0
  43. package/skills/storefront-best-practices/reference/components/navbar.md +397 -0
  44. package/skills/storefront-best-practices/reference/components/popups.md +221 -0
  45. package/skills/storefront-best-practices/reference/components/product-card.md +125 -0
  46. package/skills/storefront-best-practices/reference/components/product-reviews.md +217 -0
  47. package/skills/storefront-best-practices/reference/components/product-slider.md +174 -0
  48. package/skills/storefront-best-practices/reference/components/search.md +101 -0
  49. package/skills/storefront-best-practices/reference/connecting-to-backend.md +391 -0
  50. package/skills/storefront-best-practices/reference/design.md +388 -0
  51. package/skills/storefront-best-practices/reference/features/promotions.md +307 -0
  52. package/skills/storefront-best-practices/reference/features/wishlist.md +230 -0
  53. package/skills/storefront-best-practices/reference/layouts/account.md +380 -0
  54. package/skills/storefront-best-practices/reference/layouts/cart.md +316 -0
  55. package/skills/storefront-best-practices/reference/layouts/checkout.md +486 -0
  56. package/skills/storefront-best-practices/reference/layouts/home-page.md +264 -0
  57. package/skills/storefront-best-practices/reference/layouts/order-confirmation.md +231 -0
  58. package/skills/storefront-best-practices/reference/layouts/product-details.md +527 -0
  59. package/skills/storefront-best-practices/reference/layouts/product-listing.md +520 -0
  60. package/skills/storefront-best-practices/reference/layouts/static-pages.md +356 -0
  61. package/skills/storefront-best-practices/reference/medusa.md +307 -0
  62. package/skills/storefront-best-practices/reference/mobile-responsiveness.md +183 -0
  63. package/skills/storefront-best-practices/reference/seo.md +195 -0
  64. package/templates/app/app/[[...slug]]/page.tsx +17 -0
  65. package/templates/app/app/[[...slug]]/renderer.tsx +10 -0
  66. package/templates/app/app/globals.css +101 -0
  67. package/templates/app/app/layout.tsx +35 -0
  68. package/templates/app/lib/__STOREFRONT__/catalog.ts +132 -0
  69. package/templates/app/lib/__STOREFRONT__/handlers.ts +33 -0
  70. package/templates/app/lib/__STOREFRONT__/registry.tsx +134 -0
  71. package/templates/app/lib/__STOREFRONT__/runtime.ts +25 -0
  72. package/templates/app/lib/__STOREFRONT__/spec/home.ts +62 -0
  73. package/templates/app/lib/__STOREFRONT__/spec/index.ts +59 -0
  74. package/templates/app/lib/__STOREFRONT__/spec/types.ts +14 -0
  75. package/templates/app/lib/__STOREFRONT__/state.ts +35 -0
@@ -0,0 +1,421 @@
1
+ ---
2
+ name: storefront-best-practices
3
+ description: ALWAYS use this skill when working on ecommerce storefronts, online stores, shopping sites. Use for ANY storefront component including checkout pages, cart, payment flows, product pages, product listings, navigation, homepage, or ANY page/component in a storefront. CRITICAL for adding checkout, implementing cart, integrating Medusa backend, or building any ecommerce functionality. Framework-agnostic (Next.js, SvelteKit, TanStack Start, React, Vue). Provides patterns, decision frameworks, backend integration guidance.
4
+ ---
5
+
6
+ # Ecommerce Storefront Best Practices
7
+
8
+ Comprehensive guidance for building modern, high-converting ecommerce storefronts covering UI/UX patterns, component design, layout structures, SEO optimization, and mobile responsiveness.
9
+
10
+ ## When to Apply
11
+
12
+ **ALWAYS load this skill when working on ANY storefront task:**
13
+
14
+ - **Adding checkout page/flow** - Payment, shipping, order placement
15
+ - **Implementing cart** - Cart page, cart popup, add to cart functionality
16
+ - **Building product pages** - Product details, product listings, product grids
17
+ - **Creating navigation** - Navbar, megamenu, footer, mobile menu
18
+ - **Integrating Medusa backend** - SDK setup, cart, products, payment
19
+ - **Any storefront component** - Homepage, search, filters, account pages
20
+ - Building new ecommerce storefronts from scratch
21
+ - Improving existing shopping experiences and conversion rates
22
+ - Optimizing for usability, accessibility, and SEO
23
+ - Designing mobile-responsive ecommerce experiences
24
+
25
+ **Example prompts that should trigger this skill:**
26
+ - "Add a checkout page"
27
+ - "Implement shopping cart"
28
+ - "Create product listing page"
29
+ - "Connect to Medusa backend"
30
+ - "Add navigation menu"
31
+ - "Build homepage for store"
32
+
33
+ ## CRITICAL: Load Reference Files When Needed
34
+
35
+ **⚠️ ALWAYS load `reference/design.md` BEFORE creating ANY UI component**
36
+ - Discovers existing design tokens (colors, fonts, spacing, patterns)
37
+ - Prevents introducing inconsistent styles
38
+ - Provides guardrails for maintaining brand consistency
39
+ - **Required for every component, not just new storefronts**
40
+
41
+ **Load these references based on what you're implementing:**
42
+
43
+ - **Starting a new storefront?** → MUST load `reference/design.md` first to discover user preferences
44
+ - **Connecting to backend API?** → MUST load `reference/connecting-to-backend.md` first
45
+ - **Connecting to Medusa backend?** → MUST load `reference/medusa.md` for SDK setup, pricing, regions, and Medusa patterns
46
+ - **Implementing homepage?** → MUST load `reference/components/navbar.md`, `reference/components/hero.md`, `reference/components/footer.md`, and `reference/layouts/home-page.md`
47
+ - **Implementing navigation?** → MUST load `reference/components/navbar.md` and optionally `reference/components/megamenu.md`
48
+ - **Building product listing?** → MUST load `reference/layouts/product-listing.md` first
49
+ - **Building product details?** → MUST load `reference/layouts/product-details.md` first
50
+ - **Implementing checkout?** → MUST load `reference/layouts/checkout.md` first
51
+ - **Optimizing for SEO?** → MUST load `reference/seo.md` first
52
+ - **Optimizing for mobile?** → MUST load `reference/mobile-responsiveness.md` first
53
+
54
+ **Minimum requirement:** Load at least 1-2 reference files relevant to your specific task before implementing.
55
+
56
+ ## Planning and Implementation Workflow
57
+
58
+ **IMPORTANT: If you create a plan for implementing storefront features, include the following in your plan:**
59
+
60
+ When implementing each component, page, layout, or feature in the plan:
61
+ 1. **Refer back to this skill** before starting implementation
62
+ 2. **Load relevant reference files** listed above for the specific component/page you're building
63
+ 3. **Follow the patterns and guidance** in the reference files
64
+ 4. **Check common mistakes** sections to avoid known pitfalls
65
+
66
+ **Example plan structure:**
67
+
68
+ ```
69
+ Task 1: Implement Navigation
70
+ - Load reference/components/navbar.md
71
+ - Follow patterns from navbar.md (dynamic category fetching, cart visibility, etc.)
72
+ - Refer to skill for common mistakes (e.g., hardcoding categories)
73
+
74
+ Task 2: Implement Product Listing Page
75
+ - Load reference/layouts/product-listing.md
76
+ - Follow pagination/filtering patterns from product-listing.md
77
+ - Use reference/components/product-card.md for product grid items
78
+ - Check skill for backend integration guidance
79
+
80
+ Task 3: Implement Checkout Flow
81
+ - Load reference/layouts/checkout.md
82
+ - Load reference/medusa.md for Medusa payment integration
83
+ - Follow component architecture recommendations (separate step components)
84
+ - Refer to skill for payment method fetching requirements
85
+ ```
86
+
87
+ **Why this matters:**
88
+ - Plans provide high-level strategy
89
+ - Reference files provide detailed implementation patterns
90
+ - Skill file contains critical mistakes to avoid
91
+ - Following this workflow ensures consistency and best practices
92
+
93
+ ## Critical Ecommerce-Specific Patterns
94
+
95
+ ### Accessibility
96
+ - **CRITICAL: Cart count updates require `aria-live="polite"`** - Screen readers won't announce without it
97
+ - Ensure keyboard navigation for all cart/checkout interactions
98
+
99
+ ### Mobile
100
+ - **Sticky bottom elements MUST use `env(safe-area-inset-bottom)`** - iOS home indicator will cut off purchase buttons otherwise
101
+ - 44px minimum touch targets for cart actions, variant selectors, quantity buttons
102
+
103
+ ### Performance
104
+ - **ALWAYS add `loading="lazy"` to product images below fold** - Don't rely on browser defaults
105
+ - Optimize product images for mobile (<500KB) - Most ecommerce traffic is mobile
106
+
107
+ ### Conversion Optimization
108
+ - Clear CTAs throughout shopping flow
109
+ - Minimal friction in checkout (guest checkout if supported)
110
+ - Trust signals (reviews, security badges, return policy) near purchase buttons
111
+ - Clear pricing and shipping information upfront
112
+
113
+ ### SEO
114
+ - **Product schema (JSON-LD) required** - Critical for Google Shopping and rich snippets
115
+ - Use [PageSpeed Insights](https://pagespeed.web.dev/) to measure Core Web Vitals
116
+
117
+ ### Visual Design
118
+ - **NEVER use emojis** in storefront UI - Use icons or images instead (unprofessional, accessibility issues)
119
+
120
+ ### Backend Integration
121
+ - **Backend detection**: If in monorepo, check for backend directory. If unsure, ask user which backend is used.
122
+ - **NEVER hardcode dynamic content**: Always fetch categories, regions, products, shipping options, etc. from backend - they change frequently
123
+ - Never assume API structure - verify endpoints and data formats
124
+
125
+ ### ⚠️ CRITICAL: Backend SDK Method Verification Workflow
126
+
127
+ **YOU MUST FOLLOW THIS EXACT WORKFLOW BEFORE WRITING CODE THAT CONNECTS TO BACKEND:**
128
+
129
+ **Step 1: PAUSE - Do NOT write code yet**
130
+ - You are about to write code that calls a backend API or SDK method (e.g., Medusa SDK, REST API, GraphQL)
131
+ - **STOP** - Do not proceed to code without verification
132
+
133
+ **Step 2: QUERY the documentation or MCP server**
134
+ - **If MCP server available**: Query it for the exact method (for example, medusa MCP)
135
+ - **If no MCP server**: Search official documentation
136
+ - **Find**: Exact method name, parameters, return type
137
+
138
+ **Step 3: VERIFY what you found**
139
+ - State out loud to the user: "I need to verify the correct method for [operation]. Let me check [MCP server/documentation]."
140
+ - Show the user what you found: "According to [source], the method is `sdk.store.cart.methodName(params)`"
141
+ - Confirm the method signature and parameters
142
+
143
+ **Step 4: ONLY THEN write the code**
144
+ - Now you can write code using the verified method
145
+ - Use the exact signature you found
146
+
147
+ **Step 5: CHECK for TypeScript errors**
148
+ - After writing the code, check for any TypeScript/type errors related to the SDK
149
+ - If you see type errors on SDK methods, it means you used an incorrect method name or wrong parameters
150
+ - **Type errors are a sign you didn't verify correctly** - Go back to Step 2
151
+
152
+ **THIS IS NOT OPTIONAL - THIS IS MANDATORY ERROR PREVENTION**
153
+
154
+ **It is a CRITICAL ERROR to:**
155
+ - ❌ Write code that calls backend APIs/SDKs without explicitly querying docs/MCP first
156
+ - ❌ Guess method names or parameters
157
+ - ❌ Ignore TypeScript errors on SDK methods (errors indicate incorrect method usage)
158
+ - ❌ Copy examples from this skill without verification (examples may be outdated)
159
+ - ❌ Assume SDK methods match REST API endpoints
160
+
161
+ **For Medusa specifically:**
162
+ - **Medusa pricing**: Display prices as-is - DO NOT divide by 100 (unlike Stripe, Medusa stores prices in display format)
163
+ - **Medusa MCP server**: https://docs.medusajs.com/mcp - Recommend setup if not installed
164
+ - Load `reference/medusa.md` for Medusa-specific patterns (regions, pricing, etc.)
165
+
166
+ ### Routing Patterns
167
+ - **ALWAYS use dynamic routes** for products and categories - NEVER create static pages for individual items
168
+ - Product pages: Use dynamic routes like `/products/[handle]` or `/products/$handle`, NOT `/products/shirt.tsx`
169
+ - Category pages: Use dynamic routes like `/categories/[handle]` or `/categories/$handle`, NOT `/categories/women.tsx`
170
+ - Framework-specific patterns:
171
+ - **Next.js App Router**: `app/products/[handle]/page.tsx` or `app/products/[id]/page.tsx`
172
+ - **Next.js Pages Router**: `pages/products/[handle].tsx`
173
+ - **SvelteKit**: `routes/products/[handle]/+page.svelte`
174
+ - **TanStack Start**: `routes/products/$handle.tsx`
175
+ - **Remix**: `routes/products.$handle.tsx`
176
+ - Why: Dynamic routes scale to any number of products/categories without creating individual files
177
+ - Static routes are unmaintainable and don't scale (imagine creating 1000 product files)
178
+
179
+ ## Pattern Selection Guides
180
+
181
+ When you need to choose between implementation patterns, load the relevant reference file:
182
+
183
+ - **Checkout strategy** (single-page vs multi-step) → Load `reference/layouts/checkout.md`
184
+ - **Navigation strategy** (dropdown vs megamenu) → Load `reference/components/navbar.md` and `reference/components/megamenu.md`
185
+ - **Product listing strategy** (pagination vs infinite scroll vs load more) → Load `reference/layouts/product-listing.md`
186
+ - **Search strategy** (autocomplete vs filters vs natural language) → Load `reference/components/search.md`
187
+ - **Mobile vs desktop priorities** → Load `reference/mobile-responsiveness.md`
188
+ - **Variant selection** (text vs swatches vs configurator) → Load `reference/layouts/product-details.md`
189
+ - **Cart pattern** (popup vs drawer vs page navigation) → Load `reference/components/cart-popup.md` and `reference/layouts/cart.md`
190
+ - **Trust signals strategy** → Load `reference/layouts/product-details.md` and `reference/layouts/checkout.md`
191
+
192
+ Each reference file contains decision frameworks with specific criteria to help you choose the right pattern for your context.
193
+
194
+ ## Quick Reference
195
+
196
+ ### General
197
+
198
+ ```
199
+ reference/connecting-to-backend.md - Framework detection, API setup, backend integration patterns
200
+ reference/medusa.md - Medusa SDK integration, pricing, regions, TypeScript types
201
+ reference/design.md - User preferences, brand identity, design systems
202
+ reference/seo.md - Meta tags, structured data, Core Web Vitals
203
+ reference/mobile-responsiveness.md - Mobile-first design, responsive breakpoints, touch interactions
204
+ ```
205
+
206
+ ### Components
207
+
208
+ ```
209
+ reference/components/navbar.md - Desktop/mobile navigation, logo, menu, cart icon, load for ALL pages
210
+ reference/components/megamenu.md - Category organization, featured products, mobile alternatives
211
+ reference/components/cart-popup.md - Add-to-cart feedback, mini cart display
212
+ reference/components/country-selector.md - Country/region selection, currency, pricing, Medusa regions
213
+ reference/components/breadcrumbs.md - Category hierarchy, structured data markup
214
+ reference/components/search.md - Search input, autocomplete, results, filters
215
+ reference/components/product-reviews.md - Review display, rating aggregation, submission
216
+ reference/components/hero.md - Hero layouts, CTA placement, image optimization
217
+ reference/components/popups.md - Newsletter signup, discount popups, exit-intent
218
+ reference/components/footer.md - Content organization, navigation, social media, load for ALL pages
219
+ reference/components/product-card.md - Product images, pricing, add to cart, badges
220
+ reference/components/product-slider.md - Carousel implementation, mobile swipe, accessibility
221
+ ```
222
+
223
+ ### Layouts
224
+
225
+ ```
226
+ reference/layouts/home-page.md - Hero, featured categories, product listings
227
+ reference/layouts/product-listing.md - Grid/list views, filters, sorting, pagination
228
+ reference/layouts/product-details.md - Image gallery, variant selection, related products
229
+ reference/layouts/cart.md - Cart items, quantity updates, promo codes
230
+ reference/layouts/checkout.md - Multi-step/single-page, address forms, payment
231
+ reference/layouts/order-confirmation.md - Order number, summary, delivery info
232
+ reference/layouts/account.md - Dashboard, order history, address book
233
+ reference/layouts/static-pages.md - FAQ, about, contact, shipping/returns policies
234
+ ```
235
+
236
+ ### Features
237
+
238
+ ```
239
+ reference/features/wishlist.md - Add to wishlist, wishlist page, move to cart
240
+ reference/features/promotions.md - Promotional banners, discount codes, sale badges
241
+ ```
242
+
243
+ ## Common Implementation Patterns
244
+
245
+ ### Starting a New Storefront
246
+
247
+ **IMPORTANT: For each step below, load the referenced files BEFORE implementing that step.**
248
+
249
+ ```
250
+ 1. Discovery Phase → Read design.md for user preferences
251
+ 2. Foundation Setup → Read connecting-to-backend.md (or medusa.md for Medusa), mobile-responsiveness.md, seo.md
252
+ 3. Core Components → Implement navbar.md, footer.md
253
+ 4. Home Page → Read home-page.md
254
+ 5. Product Browsing → Read product-listing.md, product-card.md, search.md
255
+ 6. Product Details → Read product-details.md, product-reviews.md
256
+ 7. Cart & Checkout → Read cart-popup.md, cart.md, checkout.md, order-confirmation.md
257
+ 8. User Account → Read account.md
258
+ 9. Additional Features → Read wishlist.md, promotions.md
259
+ 10. Optimization → SEO audit (seo.md), mobile testing (mobile-responsiveness.md)
260
+ ```
261
+
262
+ Even if you create an implementation plan, refer back to the skill and load relevant reference files when implementing each step.
263
+
264
+ ### Shopping Flow Pattern
265
+
266
+ ```
267
+ Browse → View → Cart → Checkout
268
+
269
+ Browse: home-page.md → product-listing.md
270
+ View: product-details.md + product-reviews.md
271
+ Cart: cart-popup.md → cart.md
272
+ Checkout: checkout.md → order-confirmation.md
273
+ ```
274
+
275
+ ### Component Selection Guide
276
+
277
+ **For product grids and filtering** → `product-listing.md` and `product-card.md`
278
+ **For product cards** → `product-card.md`
279
+ **For navigation** → `navbar.md` and `megamenu.md`
280
+ **For search functionality** → `search.md`
281
+ **For checkout flow** → `checkout.md`
282
+ **For promotions and sales** → `promotions.md`
283
+
284
+ ## Design Considerations
285
+
286
+ Before implementing, consider:
287
+
288
+ 1. **User preferences** - Read `design.md` to discover design style preferences
289
+ 2. **Brand identity** - Colors, typography, tone that match the brand
290
+ 3. **Target audience** - B2C vs B2B, demographics, device usage
291
+ 4. **Product type** - Fashion vs electronics vs groceries affect layout choices
292
+ 5. **Business requirements** - Multi-currency, multi-language, region-specific
293
+ 6. **Backend system** - API structure affects component implementation
294
+
295
+ ## Integration with Medusa
296
+
297
+ [Medusa](https://medusajs.com) is a modern, flexible ecommerce backend. Consider Medusa when:
298
+
299
+ - Building a new ecommerce storefront
300
+ - Need a headless commerce solution
301
+ - Want built-in support for multi-region, multi-currency
302
+ - Need powerful promotion and discount engine
303
+ - Require flexible product modeling
304
+
305
+ For detailed Medusa integration guidance, see `reference/medusa.md`. For general backend patterns, see `reference/connecting-to-backend.md`.
306
+
307
+ ### Framework Agnostic
308
+
309
+ All guidance is framework-agnostic. Examples use React/TypeScript where code demonstrations are helpful, but patterns apply to:
310
+
311
+ - Next.js
312
+ - SvelteKit
313
+ - Tanstack Start
314
+ - Any modern frontend framework
315
+
316
+ ## Minimum Viable Features
317
+
318
+ **Mandatory for launch (core shopping flow):**
319
+ - Navbar with cart, categories, search
320
+ - Product listing with filtering and pagination
321
+ - Product details with variant selection
322
+ - Add to cart functionality
323
+ - Cart page with item management
324
+ - Checkout flow (shipping, payment, review)
325
+ - Order confirmation page
326
+
327
+ **Nice-to-have (add if time permits):**
328
+ - Related products recommendations
329
+ - Product reviews and ratings
330
+ - Wishlist functionality
331
+ - Image zoom on product pages
332
+ - Bottom navigation on mobile
333
+ - Mega-menu for navigation
334
+ - Newsletter signup
335
+ - Product comparison
336
+ - Quick view modals
337
+
338
+ **User-dependent (ask before implementing):**
339
+ - Guest checkout vs login-required
340
+ - Account dashboard features
341
+ - Multi-language support
342
+ - Multi-currency support
343
+ - Live chat support
344
+
345
+ ## Top Ecommerce Mistakes to Avoid
346
+
347
+ Before implementing, watch out for these common ecommerce-specific pitfalls:
348
+
349
+ **1. Cart and Navigation Mistakes**
350
+ - ❌ Hiding cart indicator in mobile hamburger menu (keep always visible)
351
+ - ❌ Not showing real-time cart count updates
352
+ - ❌ **CRITICAL: Missing `aria-live="polite"` on cart count** - Screen readers won't announce cart updates without it
353
+ - ❌ Not displaying variant details (size, color, etc.) in cart popup - only showing product title
354
+ - ❌ Megamenu closes when hovering over dropdown content (must stay open when hovering trigger OR dropdown)
355
+ - ❌ **CRITICAL: Megamenu positioning errors** - Three common mistakes:
356
+ - ❌ Navbar doesn't have `position: relative` (megamenu won't position correctly)
357
+ - ❌ Megamenu positioned relative to trigger button instead of navbar (use `absolute left-0` on megamenu)
358
+ - ❌ Megamenu doesn't span full width (must use `right-0` or `w-full`, not just `w-auto`)
359
+ - ❌ Hardcoding categories, featured products, or any dynamic content instead of fetching from backend
360
+ - ❌ No clear indication of current page in category navigation
361
+
362
+ **2. Product Browsing Mistakes**
363
+ - ❌ Creating static routes for products/categories (use dynamic routes like `/products/[handle]` instead of `/products/shirt.tsx`)
364
+ - ❌ Missing "no products found" empty state with helpful suggestions
365
+ - ❌ No loading indicators while fetching products
366
+ - ❌ Pagination without SEO-friendly URLs (for search engines)
367
+ - ❌ Filter selections that don't persist on page reload
368
+
369
+ **3. Product Details Mistakes**
370
+ - ❌ Enabling "Add to Cart" before variant selection (size, color, etc.)
371
+ - ❌ Missing product images optimization (large uncompressed images)
372
+ - ❌ Navigating away from product page after adding to cart (stay on page)
373
+ - ❌ Using emojis in UI instead of icons or images (unprofessional, accessibility issues)
374
+
375
+ **4. Design and Consistency Mistakes**
376
+ - ❌ **CRITICAL: Not loading `reference/design.md` before creating ANY UI component** - Leads to inconsistent colors, fonts, and styles
377
+ - ❌ Introducing new colors without checking existing theme first
378
+ - ❌ Adding new fonts without verifying what's already used
379
+ - ❌ Using arbitrary Tailwind values when theme tokens exist
380
+ - ❌ Not detecting Tailwind version (v3 vs v4) - Causes syntax errors
381
+
382
+ **5. Checkout and Conversion Mistakes**
383
+ - ❌ Requiring account creation to checkout (offer guest checkout if backend supports it)
384
+ - ❌ Not fetching payment methods from backend - assuming available payment options or skipping payment method selection
385
+ - ❌ Overly complex multi-step checkout (4+ steps kills conversion) - Optimal is 3 steps: Shipping Info, Delivery Method + Payment, Review
386
+ - ❌ Missing trust signals (secure checkout badge, return policy link)
387
+ - ❌ Not handling out-of-stock errors gracefully during checkout
388
+
389
+ **6. Mobile Experience Mistakes**
390
+ - ❌ Touch targets smaller than 44x44px (buttons, links, form fields)
391
+ - ❌ Desktop-style hover menus on mobile (use tap/click instead)
392
+ - ❌ Not optimizing images for mobile (loading huge desktop images)
393
+ - ❌ Missing mobile-specific patterns (bottom nav, drawer filters)
394
+
395
+ **7. Performance and SEO Mistakes**
396
+ - ❌ Missing structured data (Product schema) for SEO
397
+ - ❌ No explicit image lazy loading (don't assume browser defaults) - Always add `loading="lazy"` to images below the fold
398
+ - ❌ Missing meta tags and Open Graph for social sharing
399
+ - ❌ Not optimizing Core Web Vitals (LCP, FID, CLS) - Use [PageSpeed Insights](https://pagespeed.web.dev/) or Lighthouse to measure
400
+
401
+ **8. Backend Integration Mistakes**
402
+ - ❌ **ERROR: Writing code that calls backend APIs/SDKs without following the 5-step verification workflow** - You MUST: 1) PAUSE, 2) QUERY docs/MCP, 3) VERIFY with user, 4) Write code, 5) CHECK for type errors
403
+ - ❌ **ERROR: Ignoring TypeScript errors on SDK methods** - Type errors mean you used wrong method names or parameters. Go back and verify with docs/MCP
404
+ - ❌ **ERROR: Guessing API method names, SDK methods, or parameters** - Always verify exact method signatures before use
405
+ - ❌ **ERROR: Not using Medusa MCP server when available** - If using Medusa backend, always query MCP server for methods
406
+ - ❌ **ERROR: Copying code examples without verifying they're current** - Examples may be outdated, always verify first
407
+ - ❌ Not detecting which backend is being used (check monorepo, ask user if unsure)
408
+ - ❌ Assuming API structure without checking backend documentation or MCP server
409
+ - ❌ Hardcoding dynamic content (categories, regions, products, etc.) instead of fetching from backend
410
+ - ❌ Defining custom types for Medusa entities instead of using `@medusajs/types` package
411
+ - ❌ Initializing Medusa SDK without publishable API key (required for multi-region stores and product pricing)
412
+ - ❌ Fetching Medusa products without passing `region_id` query parameter (causes missing or incorrect pricing)
413
+ - ❌ Showing all countries in Medusa checkout - should only show countries from cart's region
414
+ - ❌ Dividing Medusa prices by 100 (Medusa stores prices as-is, not in cents like Stripe)
415
+ - ❌ Missing Vite SSR config for Medusa SDK (add `ssr.noExternal: ['@medusajs/js-sdk']` to vite.config.ts)
416
+ - ❌ Running Medusa storefront on port other than 8000 (causes CORS errors - Medusa backend expects port 8000 by default)
417
+ - ❌ Not handling loading, error, and empty states for API calls
418
+ - ❌ Making API calls on client-side that should be server-side (SEO, security)
419
+ - ❌ Not implementing proper error messages ("Error occurred" vs "Product out of stock")
420
+ - ❌ Missing cache invalidation (stale product data, prices, inventory)
421
+ - ❌ **Not clearing cart state after order is placed** - Cart popup shows old items because cart wasn't reset from Context/localStorage/cache
@@ -0,0 +1,123 @@
1
+ # Breadcrumbs Component
2
+
3
+ ## Contents
4
+
5
+ - [Overview](#overview)
6
+ - [When to Use Breadcrumbs](#when-to-use-breadcrumbs)
7
+ - [Ecommerce Breadcrumb Patterns](#ecommerce-breadcrumb-patterns)
8
+ - [Mobile Breadcrumbs](#mobile-breadcrumbs)
9
+ - [SEO Structured Data](#seo-structured-data)
10
+ - [Checklist](#checklist)
11
+
12
+ ## Overview
13
+
14
+ Breadcrumbs show the user's location within the site hierarchy (Home → Category → Subcategory → Product). Critical for ecommerce navigation and SEO.
15
+
16
+ **Assumed knowledge**: AI agents know how to build breadcrumbs with separators and links. This guide focuses on ecommerce-specific patterns.
17
+
18
+ ### Key Requirements
19
+
20
+ - Show full path from homepage to current page
21
+ - Each level clickable (except current page)
22
+ - Position below navbar, above page title
23
+ - Include structured data for SEO (JSON-LD)
24
+ - Mobile-optimized (back link pattern)
25
+
26
+ ## When to Use Breadcrumbs
27
+
28
+ **Use for:**
29
+ - Product pages (Home → Category → Subcategory → Product)
30
+ - Category pages (Home → Category → Subcategory)
31
+ - Deep site hierarchies (3+ levels)
32
+ - Large catalogs with many categories
33
+
34
+ **Don't use for:**
35
+ - Homepage (no parent pages)
36
+ - Flat site structures (1-2 levels)
37
+ - Checkout flow (linear, not hierarchical)
38
+ - Search results (not hierarchical)
39
+
40
+ ## Ecommerce Breadcrumb Patterns
41
+
42
+ ### Product Page Breadcrumbs
43
+
44
+ **Standard pattern:**
45
+ - Home / Category / Subcategory / Product Name
46
+ - Example: Home / Electronics / Laptops / Gaming Laptop Pro
47
+
48
+ **Key considerations:**
49
+ - All levels except product name are clickable
50
+ - Product name is current page (non-clickable, darker text)
51
+ - Shows product's location in catalog
52
+
53
+ **Multiple category membership:**
54
+ - If product in multiple categories, choose primary/canonical
55
+ - Match category in URL or navigation path
56
+ - Be consistent across site
57
+
58
+ ### Category Page Breadcrumbs
59
+
60
+ **Standard pattern:**
61
+ - Home / Parent Category / Current Category
62
+ - Example: Home / Electronics / Laptops
63
+
64
+ **Current category:**
65
+ - Non-clickable (plain text)
66
+ - Visually distinct from links (darker or bold)
67
+
68
+ ### Path Construction
69
+
70
+ **Hierarchy:**
71
+ - Start with "Home" (or home icon)
72
+ - Follow category hierarchy
73
+ - End with current page
74
+ - Maximum 5-6 levels (keep shallow)
75
+
76
+ **URL alignment:**
77
+ - Breadcrumb path should match URL hierarchy
78
+ - Consistent naming between URLs and breadcrumbs
79
+ - Example: `/categories/electronics/laptops` → "Home / Electronics / Laptops"
80
+
81
+ ## Mobile Breadcrumbs
82
+
83
+ ### Mobile Pattern: Collapse to Back Link
84
+
85
+ **Recommended approach:**
86
+ - Show only previous level as back link
87
+ - Back arrow icon (←) + parent page name
88
+ - Example: "← Gaming Laptops"
89
+
90
+ **Why:**
91
+ - Saves vertical space on mobile
92
+ - Clear affordance (back navigation)
93
+ - Simpler than full breadcrumb trail
94
+ - Mobile users have device back button
95
+
96
+ **Alternative: Truncated path**
97
+ - Show "Home ... Current Page"
98
+ - Hide middle levels
99
+ - Balances space and context
100
+
101
+ ## SEO Structured Data
102
+
103
+ **BreadcrumbList schema (CRITICAL)**: Add JSON-LD structured data. Breadcrumbs appear in search results, improves CTR, helps search engines understand site structure.
104
+
105
+ **Implementation**: schema.org BreadcrumbList with items array. Each item has position (1, 2, 3...), name, and URL. See seo.md for schema details.
106
+
107
+ ## Checklist
108
+
109
+ **Essential features:**
110
+
111
+ - [ ] Positioned below navbar, above page title
112
+ - [ ] Full path shown (Home → Category → Product)
113
+ - [ ] All levels clickable except current page
114
+ - [ ] Current page visually distinct (non-clickable, darker)
115
+ - [ ] Clear separators (›, /, > or chevron)
116
+ - [ ] Mobile: Back link pattern ("← Category")
117
+ - [ ] Structured data (JSON-LD BreadcrumbList)
118
+ - [ ] Semantic HTML (`<nav aria-label="Breadcrumb">`)
119
+ - [ ] `aria-current="page"` on current item
120
+ - [ ] Keyboard accessible (tab through links)
121
+ - [ ] Truncate long labels (20-30 characters max)
122
+ - [ ] Consistent with navigation labels
123
+ - [ ] Maximum 5-6 levels deep