Skip to main content
Skip to main content

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.

const store = await storeModuleService.create({
name: "My Store",
supported_currency_codes: ["usd"],
})

Multi-Tenancy Support

You can create multiple stores, each having its own configurations.

const store1 = await storeModuleService.create({
name: "USA Store",
supported_currency_codes: ["usd"],
})

const store2 = storeModuleService.create({
name: "Europe Store",
supported_currency_codes: [
"eur",
],
})

Configure Store Module

After installing the @medusajs/store package in your Medusa application, add it to the modules object in medusa-config.js:

medusa-config.js
const modules = {
// ...
store: {
resolve: "@medusajs/store",
},
}

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(),
})
}
Was this section helpful?