import { CodeTabs, CodeTab } from "docs-ui"

export const metadata = {
  title: `Store Module`,
}

# {metadata.title}

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.

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

### Multi-Tenancy Support

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

```ts
const stores = await storeModuleService.createStores([
  {
    name: "USA Store",
    supported_currency_codes: ["usd"],
  },
  {
    name: "Europe Store",
    supported_currency_codes: ["eur"],
  },
])
```

---

## How to Use Store Module's Service

You can use the Store Module's main service by resolving from the Medusa container the resource `ModuleRegistrationName.STORE` imported from `@medusajs/modules-sdk`.

For example:

<CodeTabs groupId="resource-type">
  <CodeTab label="API Route" value="api-route">

  ```ts title="src/api/store/custom/route.ts"
  import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
  import { IStoreModuleService } from "@medusajs/types"
  import { ModuleRegistrationName } from "@medusajs/utils"

export async function GET(
  request: MedusaRequest,
  res: MedusaResponse
): Promise<void> {
  const storeModuleService: IStoreModuleService = request.scope.resolve(
    ModuleRegistrationName.STORE
  )

  res.json({
    stores: await storeModuleService.listStores(),
  })
}
```

  </CodeTab>
  <CodeTab label="Subscriber" value="subscribers">

  ```ts title="src/subscribers/custom-handler.ts"
  import { SubscriberArgs } from "@medusajs/medusa"
  import { IStoreModuleService } from "@medusajs/types"
  import { ModuleRegistrationName } from "@medusajs/utils"

export default async function subscriberHandler({ container }: SubscriberArgs) {
  const storeModuleService: IStoreModuleService = container.resolve(
    ModuleRegistrationName.STORE
  )

  const stores = await storeModuleService.listStores()
}
```

  </CodeTab>
  <CodeTab label="Workflow Step" value="workflow-step">

  ```ts title="src/workflows/hello-world/step1.ts"
  import { createStep } from "@medusajs/workflows-sdk"
  import { IStoreModuleService } from "@medusajs/types"
  import { ModuleRegistrationName } from "@medusajs/utils"

const step1 = createStep("step-1", async (_, { container }) => {
  const storeModuleService: IStoreModuleService = container.resolve(
    ModuleRegistrationName.STORE
  )

  const stores = await storeModuleService.listStores()
})
```

  </CodeTab>
</CodeTabs>
