building-storefronts▌
medusajs/medusa-agent-skills · updated Apr 8, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
SDK-first frontend integration for Medusa storefronts with React Query patterns and critical API calling rules.
- ›Always use the Medusa JS SDK for all API requests—never use regular fetch(), as it lacks required headers (publishable API key for store routes, auth for admin routes)
- ›Pass plain JavaScript objects to SDK methods; never use JSON.stringify() on body parameters, as the SDK handles serialization automatically
- ›Use useQuery for GET requests and useMutation for POST/DELETE reques
Medusa Storefront Development
Frontend integration guide for building storefronts with Medusa. Covers SDK usage, React Query patterns, and calling custom API routes.
When to Apply
Load this skill for ANY storefront development task, including:
- Calling custom Medusa API routes from the storefront
- Integrating Medusa SDK in frontend applications
- Using React Query for data fetching
- Implementing mutations with optimistic updates
- Error handling and cache invalidation
Also load building-with-medusa when: Building the backend API routes that the storefront calls
CRITICAL: Load Reference Files When Needed
The quick reference below is NOT sufficient for implementation. You MUST load the reference file before writing storefront integration code.
Load this reference when implementing storefront features:
- Calling API routes? → MUST load
references/frontend-integration.mdfirst - Using SDK? → MUST load
references/frontend-integration.mdfirst - Implementing React Query? → MUST load
references/frontend-integration.mdfirst
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | SDK Usage | CRITICAL | sdk- |
| 2 | React Query Patterns | HIGH | query- |
| 3 | Data Display | HIGH (includes CRITICAL price rule) | display- |
| 4 | Error Handling | MEDIUM | error- |
Quick Reference
1. SDK Usage (CRITICAL)
sdk-always-use- ALWAYS use the Medusa JS SDK for ALL API requests - NEVER use regular fetch()sdk-existing-methods- For built-in endpoints, use existing SDK methods (sdk.store.product.list(),sdk.admin.order.retrieve())sdk-client-fetch- For custom API routes, usesdk.client.fetch()sdk-required-headers- SDK automatically adds required headers (publishable API key for store, auth for admin) - regular fetch() missing these headers causes errorssdk-no-json-stringify- NEVER use JSON.stringify() on body - SDK handles serialization automaticallysdk-plain-objects- Pass plain JavaScript objects to body, not stringssdk-locate-first- Always locate where SDK is instantiated in the project before using it
2. React Query Patterns (HIGH)
query-use-query- UseuseQueryfor GET requests (data fetching)query-use-mutation- UseuseMutationfor POST/DELETE requests (mutations)query-invalidate- Invalidate queries inonSuccessto refresh data after mutationsquery-keys-hierarchical- Structure query keys hierarchically for effective cache managementquery-loading-states- Always handleisLoading,isPending,isErrorstates
3. Data Display (HIGH)
display-price-format- CRITICAL: Prices from Medusa are stored as-is ($49.99 = 49.99, NOT in cents). Display them directly - NEVER divide by 100
4. Error Handling (MEDIUM)
error-on-error- ImplementonErrorcallback in mutations to handle failureserror-display- Show error messages to users when mutations failerror-rollback- Use optimistic updates with rollback on error for better UX
Critical SDK Pattern
ALWAYS pass plain objects to the SDK - NEVER use JSON.stringify():
// ✅ CORRECT - Plain object
await sdk.client.fetch("/store/reviews", {
method: "POST",
body: {
product_id: "prod_123",
rating: 5,
}
})
// ❌ WRONG - JSON.stringify breaks the request
await sdk.client.fetch("/store/reviews", {
method: "POST",
body: JSON.stringify({ // ❌ DON'T DO THIS!
product_id: "prod_123",
rating: 5,
})
})
Why this matters:
- The SDK handles JSON serialization automatically
- Using JSON.stringify() will double-serialize and break the request
- The server won't be able to parse the body
Common Mistakes Checklist
Before implementing, verify you're NOT doing these:
SDK Usage:
- Using regular fetch() instead of the Medusa JS SDK (causes missing header errors)
- Not using existing SDK methods for built-in endpoints (e.g., using sdk.client.fetch("/store/products") instead of sdk.store.product.list())
- Using JSON.stringify() on the body parameter
- Manually setting Content-Type headers (SDK adds them)
- Hardcoding SDK import paths (locate in project first)
- Not using sdk.client.fetch() for custom routes
React Query:
- Not invalidating queries after mutations
- Using flat query keys instead of hierarchical
- Not handling loading and error states
- Forgetting to disable buttons during mutations (isPending)
Data Display:
- CRITICAL: Dividing prices by 100 when displaying (prices are stored as-is: $49.99 = 49.99, NOT in cents)
Error Handling:
- Not implementing onError callbacks
- Not showing error messages to users
- Not handling network failures gracefully
How to Use
For detailed patterns and examples, load reference file:
references/frontend-integration.md - SDK usage, React Query patterns, API integration
The reference file contains:
- Step-by-step SDK integration patterns
- Complete React Query examples
- Correct vs incorrect code examples
- Query key best practices
- Optimistic update patterns
- Error handling strategies
When to Use MedusaDocs MCP Server
Use this skill for (PRIMARY SOURCE):
- How to call custom API routes from storefront
- SDK usage patterns (sdk.client.fetch)
- React Query integration patterns
- Common mistakes and anti-patterns
Use MedusaDocs MCP server for (SECONDARY SOURCE):
- Built-in SDK methods (sdk.admin., sdk.store.)
- Official Medusa SDK API reference
- Framework-specific configuration options
Why skills come first:
- Skills contain critical patterns like "don't use JSON.stringify" that MCP doesn't emphasize
- Skills show correct vs incorrect patterns; MCP shows what's possible
- Planning requires understanding patterns, not just API reference
Integration with Backend
⚠️ CRITICAL: ALWAYS use the Medusa JS SDK - NEVER use regular fetch()
When building features that span backend and frontend:
- Backend (building-with-medusa skill): Module → Workflow → API Route
- Storefront (this skill): SDK → React Query → UI Components
- Connection:
- Built-in endpoints: Use existing SDK methods (
sdk.store.product.list()) - Custom API routes: Use
sdk.client.fetch("/store/my-route") - NEVER use regular fetch() - missing publishable API key causes errors
- Built-in endpoints: Use existing SDK methods (
Why the SDK is required:
- Store routes need
x-publishable-api-keyheader - Admin routes need
Authorizationand session headers - SDK handles all required headers automatically
- Regular fetch() without headers → authentication/authorization errors
See building-with-medusa for backend API route patterns.
How to use building-storefronts on Cursor
AI-first code editor with Composer
Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add building-storefronts
Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
The skills CLI fetches building-storefronts from GitHub repository medusajs/medusa-agent-skills and configures it for Cursor.
Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
Verify installation
Confirm successful installation by checking the skill directory location:
Reload or restart Cursor to activate building-storefronts. Access the skill through slash commands (e.g., /building-storefronts) or your agent's skill management interface.
Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
List & Monetize Your Skill
Submit your Claude Code skill and start earning
Use Cases▌
Task Automation & Efficiency
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Knowledge Enhancement
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Quality Improvement
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client with skill support
- ›Clear understanding of task or problem to solve
- ›Willingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Installation Steps
- 1.Install skill using provided installation command
- 2.Test with simple use case relevant to your work
- 3.Evaluate output quality and relevance
- 4.Iterate on prompts to improve results
- 5.Integrate into regular workflow if valuable
Common Pitfalls
- ⚠Expecting perfect results without iteration
- ⚠Not providing enough context in prompts
- ⚠Using skill for tasks outside its intended scope
- ⚠Accepting outputs without review and validation
Best Practices▌
✓ Do
- +Start with clear, specific prompts
- +Provide relevant context and constraints
- +Review and refine all outputs before using
- +Iterate to improve output quality
- +Document successful prompt patterns
✗ Don't
- −Don't use without understanding skill limitations
- −Don't skip validation of outputs
- −Don't share sensitive information in prompts
- −Don't expect skill to replace human judgment
💡 Pro Tips
- ★Be specific about desired format and style
- ★Ask for multiple options to choose from
- ★Request explanations to understand reasoning
- ★Combine AI efficiency with human expertise
When to Use This▌
✓ Use When
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid When
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path▌
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.8★★★★★65 reviews- ★★★★★Arjun Brown· Dec 20, 2024
building-storefronts is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- ★★★★★Nia Ghosh· Dec 20, 2024
Solid pick for teams standardizing on skills: building-storefronts is focused, and the summary matches what you get after install.
- ★★★★★Chaitanya Patil· Dec 12, 2024
Keeps context tight: building-storefronts is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Naina White· Dec 8, 2024
building-storefronts has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Arya Sharma· Nov 27, 2024
Keeps context tight: building-storefronts is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Kofi Thomas· Nov 23, 2024
We added building-storefronts from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Soo Zhang· Nov 19, 2024
building-storefronts fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Naina Anderson· Nov 11, 2024
Solid pick for teams standardizing on skills: building-storefronts is focused, and the summary matches what you get after install.
- ★★★★★Mia Mensah· Nov 11, 2024
building-storefronts is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- ★★★★★Piyush G· Nov 3, 2024
building-storefronts has been reliable in day-to-day use. Documentation quality is above average for community skills.
showing 1-10 of 65