Store Module
The Store Module is the @medusajs/store
NPM package that provides store-related features in your Medusa and Node.js applications.
Features
Store Management
A store holds the main configurations of your commerce store, such as supported currencies, default region and sales channel, and more.
Multi-Tenancy Support
You can create multiple stores, each having its own configurations.
Configure Store Module
After installing the @medusajs/store
package in your Medusa application, add it to the modules
object in medusa-config.js
:
How to Use Store Module's Service
You can use the Store Module's main service by resolving from the dependency container the resource ModuleRegistrationName.STORE
imported from @medusajs/modules-sdk
.
For example:
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const storeModuleService: IStoreModuleService =
request.scope.resolve(ModuleRegistrationName.STORE)
res.json({
stores: await storeModuleService.list(),
})
}
import { SubscriberArgs } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
export default async function subscriberHandler({
container,
}: SubscriberArgs) {
const storeModuleService: IStoreModuleService =
container.resolve(ModuleRegistrationName.STORE)
const stores = await storeModuleService.list()
}
import { createStep } from "@medusajs/workflows-sdk"
import { IStoreModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
const step1 = createStep("step-1", async (_, context) => {
const storeModuleService: IStoreModuleService =
context.container.resolve(
ModuleRegistrationName.STORE
)
const stores = await storeModuleService.list()
})
Was this section helpful?