npm.io
2.22.7 • Published 4d ago

@medusajs/region

Licence
MIT
Version
2.22.7
Deps
0
Size
56 kB
Vulns
0
Weekly
105.2K
Stars
36.8K

Medusa logo

@medusajs/region

Documentation | Website

Building blocks for digital commerce

Medusa is released under the MIT license. PRs welcome! Discord Chat Follow @medusajs

Region Module for Medusa: manages regions and the countries that belong to them. Use it to define the markets you sell in, each with its own currency and set of countries. It ships with @medusajs/medusa and is registered by default, so Medusa applications don't install it directly.

At a glance

Package @medusajs/region
Type Commerce Module
Module key Modules.REGION ("region")
Registered by default Yes
Import from @medusajs/medusa/region

Features

  • Create regions with a currency and a list of countries.
  • Toggle automatic tax calculation per region.
  • Loads the list of countries into the database when the application starts.

Installation

No installation needed. The module is included in @medusajs/medusa and registered by default.

Usage

Resolve the module's service from the container, for example in a workflow step:

import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"

const createRegionStep = createStep(
  "create-region",
  async ({}, { container }) => {
    const regionModuleService = container.resolve(Modules.REGION)

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

    return new StepResponse({ region }, region.id)
  }
)

Resources