### Initiate MFA Setup Source: https://docs.medusajs.com/resources/references/auth/startAuthMfa Starts the multi-factor authentication setup process for a specific auth identity. ```typescript const mfaSetup = await authModuleService.startAuthMfa({ auth_identity_id: "authusr_123", provider: "totp", label: "My App", issuer: "MyCompany" }) ``` -------------------------------- ### Start Applications Source: https://docs.medusajs.com/resources/recipes/digital-products/examples/standard Commands to start the Medusa backend and the Next.js storefront. ```bash yarn run start ``` ```bash yarn dev ``` -------------------------------- ### Install qrcode package Source: https://docs.medusajs.com/resources/recipes/ticket-booking/example Install the qrcode library and its TypeScript definitions. ```bash yarn add qrcode yarn add --dev @types/qrcode ``` -------------------------------- ### Start Storefront Development Server Source: https://docs.medusajs.com/resources/how-to-tutorials/tutorials/invoice-generator Commands to navigate to the storefront directory and start the development server. ```bash ❯cd apps/storefront ``` ```bash ❯yarn dev ``` -------------------------------- ### Start Strapi Server Source: https://docs.medusajs.com/resources/integrations/guides/strapi Command to start the Strapi development server. ```bash yarn develop ``` -------------------------------- ### Install Moment.js Source: https://docs.medusajs.com/resources/recipes/subscriptions/examples/standard Command to install the Moment.js library for date manipulation. ```bash yarn add moment ``` -------------------------------- ### Install PayPal SDK Source: https://docs.medusajs.com/resources/integrations/guides/paypal Installs the PayPal server SDK required for payment processing. ```bash yarn add @paypal/paypal-server-sdk ``` -------------------------------- ### Install Dependencies Source: https://docs.medusajs.com/resources/nextjs-starter Install all project dependencies from the monorepo root. ```bash yarn install ``` -------------------------------- ### Start Medusa Server Source: https://docs.medusajs.com/resources/medusa-cli/commands/start Basic command to start the Medusa application. ```bash yarn medusa start ``` -------------------------------- ### Install Resend SDK Source: https://docs.medusajs.com/resources/integrations/guides/resend Install the Resend SDK package to enable email functionality. ```bash yarn add resend ``` -------------------------------- ### Install React Markdown Source: https://docs.medusajs.com/resources/integrations/guides/strapi Command to install the dependency required for rendering Strapi markdown descriptions. ```bash yarn add react-markdown ``` -------------------------------- ### Start Development Server Source: https://docs.medusajs.com/resources/commerce-modules/auth/reset-password Command to start the Medusa application for testing the reset password flow. ```bash yarn dev ``` -------------------------------- ### Start Development Server Source: https://docs.medusajs.com/resources/plugins/guides/wishlist Commands to start the Medusa backend development server in the apps/backend directory. ```bash * yarn * pnpm * npm ``` -------------------------------- ### Install react-jwt Source: https://docs.medusajs.com/resources/storefront-development/customers/third-party-login Command to install the react-jwt library for decoding authentication tokens. ```bash yarn add react-jwt ``` -------------------------------- ### Install Strapi Client Source: https://docs.medusajs.com/resources/integrations/guides/strapi Install the required Strapi client package in your Medusa backend directory. ```bash npm install @strapi/client ``` -------------------------------- ### Install Medusa UI Dependencies Source: https://docs.medusajs.com/resources/storefront-development/guides/express-checkout Install the core Medusa UI library, presets, and icons. ```bash yarn add @medusajs/ui@latest @medusajs/ui-preset@latest @medusajs/icons@latest ``` -------------------------------- ### Install Meilisearch Dependencies Source: https://docs.medusajs.com/resources/integrations/guides/meilisearch Install the required Meilisearch InstantSearch and React InstantSearch packages. ```bash yarn add @meilisearch/instant-meilisearch react-instantsearch ``` -------------------------------- ### Install Algolia Client Source: https://docs.medusajs.com/resources/integrations/guides/algolia Installs the Algolia JavaScript client dependency in the project root. ```bash yarn add algoliasearch ``` -------------------------------- ### Install Draft Orders Plugin Source: https://docs.medusajs.com/resources/commerce-modules/order/draft-orders Install the plugin package using your preferred package manager. ```bash yarn add @medusajs/draft-order ``` -------------------------------- ### Install Algolia Dependencies Source: https://docs.medusajs.com/resources/integrations/guides/algolia Install the necessary Algolia search client and React InstantSearch packages. ```bash ❯yarn add algoliasearch react-instantsearch ``` -------------------------------- ### Install Contentful Node Apps Toolkit Source: https://docs.medusajs.com/resources/integrations/guides/contentful Install the required package for verifying webhook requests. ```bash yarn add @contentful/node-apps-toolkit ``` -------------------------------- ### Install Stripe SDKs Source: https://docs.medusajs.com/resources/storefront-development/checkout/payment/stripe Install the necessary Stripe React and JS packages using your preferred package manager. ```bash yarn add @stripe/react-stripe-js @stripe/stripe-js ``` -------------------------------- ### Create Integration Test Setup File Source: https://docs.medusajs.com/resources/troubleshooting/test-errors Clear metadata storage in your integration test setup file to prevent incompatible receiver errors. ```javascript const { MetadataStorage } = require("@medusajs/framework/mikro-orm/core") MetadataStorage.clear() ``` -------------------------------- ### Install Medusa JS SDK Source: https://docs.medusajs.com/resources/js-sdk Command to install the SDK and types library in external projects like custom storefronts. ```bash yarn add @medusajs/js-sdk@latest @medusajs/types@latest ``` -------------------------------- ### Install Contentful Rich Text Package Source: https://docs.medusajs.com/resources/integrations/guides/contentful Command to install the necessary package for rendering Contentful rich-text fields. ```bash yarn add @contentful/@contentful/rich-text-types ``` -------------------------------- ### Navigate and start the development server Source: https://docs.medusajs.com/resources/medusa-cli/commands/new Commands to enter the newly created directory and launch the development environment. ```bash cd my-medusa-store yarn dev ``` -------------------------------- ### Implement get Method Source: https://docs.medusajs.com/resources/infrastructure-modules/cache/create Example implementation of the get method using Memcached to retrieve cached items. ```typescript class MyCacheService implements ICacheService { // ... async get(cacheKey: string): Promise { return new Promise((res, rej) => { this.memcached.get(cacheKey, (err, data) => { if (err) { res(null) } else { if (data) { res(JSON.parse(data)) } else { res(null) } } }) }) } } ``` -------------------------------- ### importProductsWorkflow Source: https://docs.medusajs.com/resources/references/medusa-workflows/importProductsWorkflow Example of how to invoke the importProductsWorkflow within an API route to start a product import. ```APIDOC ## POST /api/workflow ### Description Initiates a product import process using the importProductsWorkflow. The workflow processes a CSV file provided in the input and returns a transaction ID for subsequent confirmation. ### Request Body - **fileContent** (string) - Required - The CSV content to be imported. - **filename** (string) - Required - The name of the file being imported. ### Request Example { "fileContent": "title,description\nShirt,This is a shirt", "filename": "products.csv" } ### Response #### Success Response (200) - **result** (object) - The result of the workflow execution. - **transaction.transactionId** (string) - The ID required to confirm the import via the Workflow Engine. ``` -------------------------------- ### Install Medusa with Next.js Starter Source: https://docs.medusajs.com/resources/nextjs-starter Use this command to initialize a new Medusa project that includes the Next.js Starter storefront. ```bash yarn dlx create-medusa-app@latest --with-nextjs-starter ``` -------------------------------- ### Claude Code Prompts Source: https://docs.medusajs.com/resources/storefront-development Example prompts for generating storefront features using the installed skills. ```text ❯Build a Next.js ecommerce storefront that uses Medusa as the backend. The storefront should have product listing, product detail, cart, and checkout pages.❯Add a megamenu to the storefront's header that displays product categories and subcategories. The menu should be responsive and work well on mobile devices. ``` -------------------------------- ### Start Medusa Application Source: https://docs.medusajs.com/resources/infrastructure-modules/event/redis Run the development server to initialize the module. ```bash ❯yarn dev ``` -------------------------------- ### Setup Database Source: https://docs.medusajs.com/resources/medusa-cli/commands/db Recreates and reinitializes the database after a reset. Requires the database name as an argument. ```bash yarn medusa db:setup --db ``` -------------------------------- ### Setup Database with Medusa CLI Source: https://docs.medusajs.com/resources/medusa-cli/commands/db Creates a database, runs migrations, and syncs links. Updates the .env file with the specified database name. ```bash yarn medusa db:setup --db ``` -------------------------------- ### Initialize Environment File Source: https://docs.medusajs.com/resources/nextjs-starter Create the local environment configuration file from the provided template. ```bash cp apps/storefront/.env.template apps/storefront/.env.local ``` -------------------------------- ### Create a project named my-medusa-store Source: https://docs.medusajs.com/resources/medusa-cli/commands/new Example of running the new command with a specific directory name. ```bash medusa new my-medusa-store ``` -------------------------------- ### Install Medusa Application Source: https://docs.medusajs.com/resources/how-to-tutorials/tutorials/abandoned-cart Command to initialize a new Medusa project using the CLI. ```bash yarn dlx create-medusa-app@latest ``` -------------------------------- ### Non-compliant import example Source: https://docs.medusajs.com/resources/lint/rules/no-mikroorm-direct-import Example of an import that triggers the no-mikroorm-direct-import rule. ```typescript // non-compliant import { EntityManager } from "@mikro-orm/core" ``` -------------------------------- ### Run the build command Source: https://docs.medusajs.com/resources/medusa-cli/commands/build Executes the build process to prepare the application for production deployment. ```bash yarn medusa build ``` -------------------------------- ### Start Development Servers Source: https://docs.medusajs.com/resources/storefront-development/guides/react-native-expo Commands to launch the Medusa backend and the Expo development server. ```bash ❯npm run dev ``` ```bash ❯npm run start ``` -------------------------------- ### Install PDF generation dependencies Source: https://docs.medusajs.com/resources/how-to-tutorials/tutorials/invoice-generator Install the pdfmake library and its TypeScript definitions. ```bash yarn add pdfmake yarn add --dev @types/pdfmake ``` -------------------------------- ### Navigate to Storefront Directory Source: https://docs.medusajs.com/resources/troubleshooting/create-medusa-app-errors Change the current working directory to the storefront folder created by the installation process. ```bash cd my-medusa-store-storefront ``` -------------------------------- ### Install jsonwebtoken dependency Source: https://docs.medusajs.com/resources/plugins/guides/wishlist Install the required package for token generation in your plugin project. ```bash yarn pnpm npm ``` -------------------------------- ### Clone DTC Starter for Manual Installation Source: https://docs.medusajs.com/resources/nextjs-starter Clone the repository into a temporary directory to extract the storefront files. ```bash git clone https://github.com/medusajs/dtc-starter.git --depth=1 dtc-temp ``` -------------------------------- ### Install Payload Dependencies Source: https://docs.medusajs.com/resources/integrations/guides/payload Install the required Payload CMS packages for the Next.js storefront. ```bash yarn add payload @payloadcms/next @payloadcms/richtext-lexical sharp @payloadcms/db-postgres graphql ``` -------------------------------- ### Start Strapi Development Server Source: https://docs.medusajs.com/resources/integrations/guides/strapi Launches the Strapi application in development mode. ```bash npm run dev ``` -------------------------------- ### Install Sentry Dependencies Source: https://docs.medusajs.com/resources/integrations/guides/sentry Install the required Sentry and OpenTelemetry packages for Medusa instrumentation. ```bash yarn add @sentry/node @opentelemetry/api @opentelemetry/exporter-trace-otlp-grpc @sentry/opentelemetry-node @opentelemetry/core@1.x @opentelemetry/sdk-trace-base@1.x @opentelemetry/semantic-conventions@1.x ``` -------------------------------- ### Initialize Next.js Project Source: https://docs.medusajs.com/resources/storefront-development/guides/express-checkout Command to create a new Next.js application. ```bash yarn dlx create-next-app@latest express-checkout ``` -------------------------------- ### Upsert Stock Location Addresses Example Source: https://docs.medusajs.com/resources/references/stock-location-next/upsertStockLocationAddresses Basic usage example for the upsertStockLocationAddresses method. ```typescript {example-code} ``` -------------------------------- ### Invalid Workflow ID Example Source: https://docs.medusajs.com/resources/lint/rules/workflow-id-matches-export-or-filename An example of a workflow ID that triggers the rule because it is not in kebab-case. ```typescript import { createWorkflow, WorkflowResponse, } from "@medusajs/framework/workflows-sdk" export const helloWorldWorkflow = createWorkflow( "helloWorldWorkflow", (input) => { return new WorkflowResponse({ ok: true }) } ) ``` -------------------------------- ### Run Email Development Server Source: https://docs.medusajs.com/resources/integrations/guides/resend Command to start the development server for previewing email templates. ```bash yarn dev:email ``` -------------------------------- ### Register Customer Source: https://docs.medusajs.com/resources/examples/guides/quote-management Create a new customer account using the registration token. ```bash curl -X POST 'http://localhost:9000/store/customers' \ -H 'Authorization: Bearer {token}' \ -H 'Content-Type: application/json' \ -H 'x-publishable-api-key: {your_publishable_api_key}' \ --data-raw '{ "email": "customer@gmail.com" }' ``` -------------------------------- ### Non-compliant import example Source: https://docs.medusajs.com/resources/lint/rules/import-from-framework-not-internal Example of an import that triggers the rule by using a deprecated package. ```typescript // non-compliant import { MedusaError } from "@medusajs/utils" ``` -------------------------------- ### Install Multer Dependencies Source: https://docs.medusajs.com/resources/recipes/digital-products/examples/standard Installs the necessary packages to handle file uploads in the Medusa application. ```bash ❯yarn add multer❯yarn add --dev @types/multer ``` -------------------------------- ### Create and accept user invites Source: https://docs.medusajs.com/resources/commerce-modules/user/user-creation-flows Manage user onboarding by creating invites, validating tokens, and converting invites into user records. ```javascript 1const invite = await userModuleService.createInvites({ 2 email: "user@example.com", 3}) ``` ```javascript 1const invite = 2 await userModuleService.validateInviteToken("secret_123") 3 4await userModuleService.updateInvites({ 5 id: invite.id, 6 accepted: true, 7}) 8 9const user = await userModuleService.createUsers({ 10 email: invite.email, 11}) ``` -------------------------------- ### Create a Customer Account Source: https://docs.medusajs.com/resources/plugins/guides/wishlist Registers the customer in the store using the publishable API key and the registration token. ```bash curl -X POST 'http://localhost:9000/store/customers' \ --header 'Content-Type: application/json' \ -H 'x-publishable-api-key: {api_key}' \ --header 'Authorization: Bearer {token}' \ --data-raw '{ "email": "customer@gmail.com" }' ``` -------------------------------- ### Install PayPal React SDK Source: https://docs.medusajs.com/resources/integrations/guides/paypal Command to add the PayPal React SDK dependency to the storefront project. ```bash yarn add @paypal/react-paypal-js ``` -------------------------------- ### Install Medusa ESLint Plugin Source: https://docs.medusajs.com/resources/lint Install the plugin along with ESLint and jiti as development dependencies. ```bash yarn add --dev @medusajs/eslint-plugin eslint jiti ``` -------------------------------- ### Initialize a new Medusa project Source: https://docs.medusajs.com/resources/create-medusa-app Run this command to scaffold a new Medusa project in a directory named after the project-name. ```bash ❯yarn dlx create-medusa-app@latest [project-name] ``` -------------------------------- ### Initialize Sanity CLI Source: https://docs.medusajs.com/resources/integrations/guides/sanity Run this command within the storefront directory to start the Sanity configuration process. ```bash npx sanity@latest init ``` -------------------------------- ### Install Medusa with Custom Database Port Source: https://docs.medusajs.com/resources/troubleshooting/database-errors Command to initialize a Medusa project using a specific database URL and port. ```bash yarn dlx create-medusa-app@latest --db-url "postgres://user:password@localhost:/medusa-store" ``` -------------------------------- ### Verify Local Event Bus Installation Source: https://docs.medusajs.com/resources/infrastructure-modules/event/local Check terminal logs for the installation confirmation message. ```text Local Event Bus installed. This is not recommended for production. ``` -------------------------------- ### Initialize Product Detail Screen Component Source: https://docs.medusajs.com/resources/storefront-development/guides/react-native-expo Sets up the basic structure and state variables for the product detail screen. ```typescript 1import { ProductImageSlider } from "@/components/product-image-slider" 2import { ProductSkeleton } from "@/components/product-skeleton" 3import { Button } from "@/components/ui/button" 4import { Toast } from "@/components/ui/toast" 5import { Colors } from "@/constants/theme" 6import { useCart } from "@/context/cart-context" 7import { useRegion } from "@/context/region-context" 8import { useColorScheme } from "@/hooks/use-color-scheme" 9import { formatPrice } from "@/lib/format-price" 10import { isVariantInStock } from "@/lib/inventory" 11import { sdk } from "@/lib/sdk" 12import type { HttpTypes } from "@medusajs/types" 13import { useLocalSearchParams, useNavigation } from "expo-router" 14import React, { useCallback, useEffect, useMemo, useState } from "react" 15import { ScrollView, StyleSheet, Text, TouchableOpacity, View } from "react-native" 16 17export default function ProductDetailsScreen() { 18 const { id, title } = useLocalSearchParams<{ id: string; title?: string }>() 19 const colorScheme = useColorScheme() 20 const colors = Colors[colorScheme ?? "light"] 21 const { addToCart } = useCart() 22 const { selectedRegion } = useRegion() 23 24 const [product, setProduct] = useState(null) 25 const [selectedOptions, setSelectedOptions] = useState>({}) 26 const [quantity, setQuantity] = useState(1) 27 const [loading, setLoading] = useState(true) 28 const [addingToCart, setAddingToCart] = useState(false) 29 const [error, setError] = useState(null) 30 const [toastVisible, setToastVisible] = useState(false) 31 const [toastMessage, setToastMessage] = useState("") 32 const navigation = useNavigation() 33 34 // TODO fetch product 35} 36 37const styles = StyleSheet.create({ 38 container: { 39 flex: 1, ``` -------------------------------- ### Navigate to Storefront Directory Source: https://docs.medusajs.com/resources/how-to-tutorials/tutorials/re-order Command to enter the storefront directory within the project. ```bash ❯cd apps/storefront ``` -------------------------------- ### Reported Code Example Source: https://docs.medusajs.com/resources/lint/rules/use-inject-manager-on-public-methods An example of a service method that triggers the rule because it lacks the required decorator. ```typescript import { MedusaService } from "@medusajs/framework/utils" class BlogModuleService extends MedusaService({}) { async list(sharedContext: Context = {}) {} } ```