Region Module
The Region Module is the @medusajs/region
NPM package that provides region-related features in your Medusa and Node.js applications.
What is a Region?
A region represents the area you sell products in. Each region can cover multiple countries, but uses a single currency.
Features
Region Management
You can manage your regions to create, update, retrieve, or delete them.
Multi-Currency Support
As each region has a currency, you can support multiple currencies in your store by creating multiple regions.
Different Settings Per Region
Each region has its own settings, such as what countries belong to a region or its tax settings. When using other commerce modules such as the Tax Module or Payment Module, each region has different tax rates, payment providers, and more.
Configure Region Module
After installing the @medusajs/region
package in your Medusa application, add it to the modules
object in medusa-config.js
:
How to Use Region Module's Service
You can use the Region Module's main service by resolving from the dependency container the resource ModuleRegistrationName.REGION
imported from @medusajs/modules-sdk
.
For example:
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IRegionModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService =
req.scope.resolve(ModuleRegistrationName.REGION)
res.json({
regions: await regionModuleService.list(),
})
}
import { SubscriberArgs } from "@medusajs/medusa"
import { IRegionModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
export default async function subscriberHandler({
container,
}: SubscriberArgs) {
const regionModuleService: IRegionModuleService =
container.resolve(ModuleRegistrationName.REGION)
const regions = await regionModuleService.list()
}
import { createStep } from "@medusajs/workflows-sdk"
import { IRegionModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
const step1 = createStep("step-1", async (_, context) => {
const regionModuleService: IRegionModuleService =
context.container.resolve(
ModuleRegistrationName.REGION
)
const regions = await regionModuleService.list()
})