Skip to main content
Skip to main content

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.

const region = await regionModuleService.create({
name: "Europe",
currency_code: "eur",
})

Multi-Currency Support

As each region has a currency, you can support multiple currencies in your store by creating multiple regions.

const regions = await regionModuleService.create([
{
name: "Europe",
currency_code: "eur",
},
{
name: "United States of America",
currency_code: "usd",
},
])

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.

const regions = await regionModuleService.create([
{
name: "Europe",
currency_code: "eur",
countries: ["dk", "de", "fr", "it", "pt"],
automatic_taxes: true,
},
{
name: "United States of America",
currency_code: "usd",
countries: ["us"],
automatic_taxes: false,
},
])

Configure Region Module

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

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

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