medusa Documentation

The world's most flexible commerce platform for agents and developers

35,754 stars TypeScript TypeScript 1 file Β· ~17,054 tokens #ai-coding#ai-tools#commerce#e-commerce#ecommerce#framework#javascript#medusa
RAW Doc

File: README.md

Medusa

[Documentation](https://docs.medusajs.com) | [Website](https://www.medusajs.com)

Getting Started

The fastest way to get started is with Medusa Cloud. It provides a managed environment optimized for Medusa applications, with automated deployments, scaling, and maintenance. Get started on Medusa Cloud

To set up a Medusa application locally, visit the Documentation.

About Medusa

Medusa is a commerce platform with a built-in framework for customization that allows you to build custom commerce applications without reinventing core commerce logic. The framework and modules can be used to support advanced B2B or DTC commerce stores, marketplaces, distributor platforms, PoS systems, service businesses, or similar solutions that need foundational commerce primitives. Medusa's core commerce modules are open-source and freely available on npm. Enterprise Edition features are identified separately in the repository.

Learn more about Medusa’s architecture and commerce modules in the Docs.

Upgrades & Integrations

Follow the Release Notes to keep your Medusa project up-to-date.

Check out all available Medusa integrations.

Community & Contributions

The core team is available in GitHub Discussions, where you can create issues, share ideas, and discuss roadmap.

Our Contribution Guide describes how to contribute to the codebase and Docs.

Join our Discord server to meet and discuss with more than 14,000 other community members.

Other channels

License

Medusa uses an open-core model. The core is licensed under the MIT License. The RBAC-based Enterprise Edition materials identified in ENTERPRISE-LICENSE.md require a commercial agreement with MedusaJS, Inc.


File: docs/content/cli/reference.md



CLI Reference

This document serves as a reference to the Medusa CLI tool including how to install it and what commands are available.

Overview

The Medusa CLI serves as a tool that allows you to perform important commands while developing with Medusa.

To use Medusa, it is required to install the CLI tool as it is used to create a new Medusa backend.


How to Install CLI Tool

To install the CLI tool, run the following command in your terminal:

bash npm2yarn
npm install @medusajs/medusa-cli -g

:::note

If you run into any errors while installing the CLI tool, check out the troubleshooting guide.

:::

The CLI tool is then available under the medusa command. You can see all commands and options with the following command:

bash
medusa --help

Common Options

The following options can be used with all available commands.

--help

Learn more about what you can do with the CLI tool or with a specific command.

Alias: -h

bash
medusa new --help

--verbose

Turn on verbose output for detailed logs.

Default: false

bash
medusa new my-backend --verbose

--no-color

Turn off colors in the output.

Alias: --no-colors

Default: false

bash
medusa new my-backend --no-color

--json

Turn on JSON logger.

Default: false

bash
medusa new my-backend --json

--version

If used inside a Medusa project, the version of the Medusa CLI and Medusa project is shown. Otherwise, the version of the Medusa CLI is shown.

Alias: -v

bash
medusa --version

Available Commands

new

Create a new Medusa backend.

bash
medusa new [ [<starter_url>]]

Arguments

Name Description Default
backend_name The name of the Medusa backend. It will be used as the name of the directory created. If not provided, you’ll be prompted to enter it.
starter_url The URL of the starter to create the backend from. The default starter is used.

Options

Name Description
--seed If the flag is set the command will attempt to seed the database after setup.
-y, --useDefaults If the flag is set the command will not interactively collect database credentials.
--skip-db If the flag is set the command will not attempt to complete the database setup.
--skip-migrations If the flag is set the command will not attempt to complete the database migration.
--skip-env If the flag is set the command will not attempt to populate .env.
--db-user The database user to use for database setup and migrations.
--db-database The database used for database setup and migrations.
--db-pass The database password to use for database setup and migrations.
--db-port The database port to use for database setup and migrations.
--db-host The database host to use for database setup and migrations.

develop

Start development backend. This command watches files for any changes to rebuild the files and restart the backend.

bash
medusa develop

Options

Name Description
-H, --host Set host. Defaults to localhost.
-p, --port Set port. Defaults to 9000.

start

Start development backend. This command does not watch for file changes or restart the backend.

bash
medusa start

Options

Name Description
-H, --host Set host. Defaults to localhost.
-p, --port Set port. Defaults to 9000.

migrations

Migrate the database to the most recent version.

bash
medusa migrations <action>

Arguments

Name Description Default
action The action to perform. Values can be run, show, or revert. run is used to run the migrations; show is used to only show what migrations are available to run; and revert is to undo the last migration. This argument is required and does not have a default value.

seed

Migrates and populates the database with the provided file.

bash
medusa seed --seed-file=<file_path>

Options

Name Description
-f, --seed-file Path to the file where the seed is defined. (required)
-m, --migrate Flag to indicate if migrations should be run prior to seeding the database. Default is true.

user

Creates a new admin user.

bash
medusa user --email  [--password ]

Options

Name Description
-e, --email The email to create a user with. (required)
-p, --password The password to use with the user. If not included, the user will not have a password.
-i, --id The user’s ID. By default it is automatically generated.

telemetry

Enable or disable the collection of anonymous data usage. If no option is provided, the command will enable the collection of anonymous data usage.

bash
medusa telemetry

Options

Name Description
--enable Enable telemetry (default)
--disable Disable telemetry

See Also


File: docs/content/admin/development.md


addHowToData: true

Customize Medusa Admin

In this document, you’ll learn how to customize the Medusa admin by forking it, and how to keep it updated with changes from the main repository.

Overview

Although Medusa provides an intuitive admin that should cover all your ecommerce needs, you are free to customize the Medusa admin as you see fit.

For customization and development, it’s recommended that you fork the main Medusa admin repository. That way, you can configure your forked repository to pull changes from the main Medusa admin repository for any latest updates.

In this document, you’ll learn how to:

  • Fork the Medusa admin repository.
  • Configure the Medusa admin repository as an upstream repository.
  • Pull changes from the upstream repository to keep your fork synced with the Medusa admin repository.

Prerequisites

Required Tools

Git CLI tool

Required Accounts

GitHub


Fork the Medusa Admin Repository

To fork the Medusa admin:

  1. Go to the Medusa admin repository.
  2. Click on the Fork button at the top right.
  3. You can optionally change the name of the repository and description.
  4. Once done, click on the Create fork button.
  5. After your fork is created, you can clone it using the following command:
bash
git clone <REPOSITORY_URL>

Where <REPOSITORY_URL> is the HTTPS URL of your repository. You can obtain it from your forked repository’s GitHub page by clicking on the Code button and copying the URL.


Configure Upstream Repository

To configure the Medusa admin as the upstream repository:

  1. Change to the directory of your cloned forked repository.
  2. Run the following command to add the Medusa admin repository as an upstream repository:
bash
git remote add upstream https://github.com/medusajs/admin
  1. You can verify that it has been added by running the following command:
bash
git remote -v

You should see an origin repository which is your forked repository, and an upstream repository which is the Medusa admin repository.


Update your Fork with Latest Changes

To update your fork with the latest changes from the Medusa admin repository:

  1. Change to the directory of your cloned forked repository.
  2. Run the following command to fetch the latest changes from the Medusa admin repository:
bash
git fetch upstream
  1. Make sure you’re on your main or master branch of the forked repository:
bash
git checkout main
  1. Merge the changes from the main branch of the Medusa admin repository:
bash
git merge upstream/main

If your forked repository doesn’t have any conflicts with the changes from the Medusa admin repository, the merge will be done successfully. Otherwise, you’ll need to resolve these conflicts.


See Also


File: docs/content/admin/quickstart.mdx


addHowToData: true

import Feedback from '@site/src/components/Feedback';

Admin Dashboard Quickstart

This document will guide you through setting up the admin dashboard in the Medusa backend.

:::note

The admin dashboard is now shipped as an NPM package, and the previous GitHub repository has been deprecated.

:::

Overview

The admin dashboard is installed on the Medusa backend. Setting it up depends on how you intend to use it:

  1. Served alongside the Medusa backend: with this approach, the admin dashboard starts when you start the Medusa backend. This also means you can later deploy the Medusa backend along with the admin dashboard on the same hosting.
  2. Served separately from the Medusa backend: with this approach, the admin dashboard starts separately from the Medusa backend. You still need the Medusa backend to be running as the admin uses its APIs. This is useful if you intend to later deploy the admin dashboard on a different hosting than the Medusa Backend, such as using Vercel.

This guide will explain the steps and configurations required for both approaches.


Prerequisites

Medusa Backend

As the admin dashboard is a plugin installed on the Medusa Backend, you must have a Medusa Backend installed first. You can learn how to install it in this documentation.

Node.js

The Admin uses Vite v4.1.4 which requires v14.8+ or v16+ of Node.js, and as Medusa requires v16 or greater it's recommended you use v16+ of Node.js.

You can check which version of Node you have by running the following command:

bash noreport
node -v

You can install Node from the official website.


Option 1: Install and Serve Admin with the Backend

This section explains how to install the admin to be served with the Medusa Backend and later deployed together.

:::note

If you decide later to serve the admin for development separately or deploy it on a different hosting, you can go back and follow the steps in Option 2.

:::

Step 1: Install the Package

In the directory of your Medusa backend, run the following command to install admin dashboard:

bash npm2yarn
npm install @medusajs/admin

Step 2: Add Admin to Medusa Configurations

In medusa-config.js, add the admin plugin into the array of plugins:

js title=medusa-config.js
const plugins = [
  // ...
  {
    resolve: "@medusajs/admin",
    /** @type {import('@medusajs/admin').PluginOptions} */
    options: {
      // ...
    },
  },
]

The plugin accepts the following options:

  1. serve: (default: true) a boolean indicating whether to serve the admin dashboard when the Medusa backend starts. If set to false, you can serve the admin dashboard using the dev command.
  2. path: (default: app) a string indicating the path the admin server should run on. It shouldn't be prefixed or suffixed with a slash /, and it can't be one of the reserved paths: "admin" and "store".
  3. outDir: Optional path for where to output the admin build files.
  4. autoRebuild: (default: false) a boolean indicating whether the admin UI should be rebuilt if there are any changes or if a missing build is detected when the backend starts. If not set, you must manually build the admin dashboard.

Optional: Manually Building Admin Dashboard

If you have autoRebuild disabled, you must build your admin dashboard before starting the Medusa backend. Refer to the build command for more details.

Step 3: Test the Admin Dashboard

:::tip

If you disabled the serve option, you need to run the admin dashboard separately using the dev command

:::

You can test the admin dashboard by running the following command in the directory of the Medusa backend:

bash npm2yarn
npm run start

This starts the Medusa Backend and the admin dashboard. By default, the admin will be available on the URL localhost:9000/app. If you set the path option, then the admin will be available on localhost:9000/ with `` being the value of the path option.


Option 2: Install and Serve Admin Separately

This section explains how to install the admin dashboard using approach 2, which allows you to serve and later deploy the admin separately.

:::note

If you decide later to serve and deploy the admin alongside the server, you can go back and follow the steps in Option 1.

:::

Step 1: Install the Package

In the directory of your Medusa backend, run the following command to install admin dashboard:

bash npm2yarn
npm install @medusajs/admin --save-dev

Step 2: Add Scripts to Package.json

Add the following scripts to package.json in the directory of the Medusa backend:

json title=package.json
{
  "scripts": {
    // other scripts...
    "build:admin": "medusa-admin build",
    "dev:admin": "medusa-admin dev"
  }
}

Where:

  • build:admin: Used to manually create a build of the admin. In this approach, it's useful with the --deployment option to build the admin for deployment. You can learn more about all available options in this section.
  • dev:admin: Used to run the development server of the admin. You can learn about other available options for this command in this section.

Step 3: Start Admin in Development

Make sure to run the Medusa backend first. Then, in the root directory of the backend, run the following command to start the admin development server:

bash npm2yarn
npm run dev:admin

This runs the admin dashboard on localhost:7001.


Demo Credentials

If you installed the demo data when you installed the Medusa backend by using the --seed option or running:

bash npm2yarn
npm run seed

You can use the email [email protected] and password supersecret to log in.

:::info

Passwords in Medusa are hashed using the scrypt-kdf. The password hash is then stored in the database.

:::


Create a New Admin User

To create a new admin user from the command line, run the following command in the directory holding your Medusa backend:

bash
medusa user -e [email protected] -p some-password

This will create a new user that you can use to log into your admin panel.


Build Command Options

The build command in the admin CLI allows you to manually build the admin dashboard. If you intend to use it, you should typically add it to the package.json of the Medusa backend:

json title=package.json
{
  "scripts": {
    // other scripts...
    "build:admin": "medusa-admin build"
  }
}

You can add the following options to the medusa-admin build command:

  • --deployment: a boolean value indicating that the build should be ready for deployment. When this option is added, options are not loaded from medusa-config.js anymore, and it means the admin will be built to be hosted on an external host. For example, medusa-admin build --deployment.
  • --backend or -b: a string specifying the URL of the Medusa backend. This can be useful with the --deployment option. The default here is the value of the environment variable MEDUSA_BACKEND_URL. For example, medusa-admin build --deployment --backend example.com
  • --out-dir or -o: a string specifying a custom path to output the build files to. By default, it will be the build directory. For example, medusa-admin --deployment --out-dir public.
  • --include or -i: a list of strings of paths to files you want to include in the build output. It can be useful if you want to inject files that are relevant to your external hosting, such as adding a 200.html file that is needed for redirects on Surge. For example, medusa-admin --deployment --include 200.html
  • --include-dist or -d: a string specifying the path to copy the files specified in --include to. By default, the files are coopied to the root of the build directory. You can use this option to change that. For example, medusa-admin --deployment --include 200.html --include-dist static.

Dev Command Options

The dev command in the admin CLI allows you to run the admin dashboard in development separately from the Medusa backend. If you intend to use it, you should typically add it to the package.json of the Medusa backend:

json title=package.json
{
  "scripts": {
    // other scripts...
    "dev:admin": "medusa-admin dev"
  }
}

You can add the following options to the medusa-admin dev command:

  • --backend or -b: a string specifying the URL of the Medusa backend. By default, it's the value of the environment variable MEDUSA_BACKEND_URL. For example, medusa-admin dev --backend example.com.
  • --port or -p: the port to run the admin on. By default, it's 7001. For example, medusa-admin dev --port 8000.

Admin User Guide

The admin dashboard provides a lot of ecommerce features including managing Return Merchandise Authorization (RMA) flows, store settings, products, orders, and much more.

You can learn more about the admin dashboard and its features in the User Guide.


File: docs/content/deployments/admin/deploying-on-vercel.md


addHowToData: true

Deploy Admin to Vercel

In this document, you’ll learn how to deploy the admin dashboard to Vercel.

Prerequisites

Medusa Components

You must have a Medusa backend installed along with an admin dashboard plugin.

Required Accounts

:::note

If you want to use another Git Provider, it’s possible to follow along with this guide, but you’ll have to perform the equivalent steps in your Git Provider.

:::

Required Tools

  • Git CLI: Only required if you’re deploying through the Vercel website.

Step 1: Create GitHub Repository

:::note

This step is only required if you’re deploying from the Vercel website. However, it’s highly recommended to connect your Vercel project to a Git repository for a better developer experience.

:::

Before you can deploy your admin dashboard, you need to create a GitHub repository and push the code base to it. To do that:

  1. On GitHub, click the plus icon at the top right, then click New Repository.
  2. You’ll then be redirected to a new page with a form. In the form, enter the Repository Name.
  3. Scroll down and click Create repository.

Push Code to GitHub Repository

The next step is to push the code to the GitHub repository you just created.

After creating the repository, you’ll be redirected to the repository’s page. On that page, you should see a URL that you can copy to connect your repository to a local directory.

Copy the link. Then, open your terminal in the directory that holds your Medusa backend codebase and run the following commands:

bash
git init
git remote add origin <GITHUB_URL>

WhereΒ <GITHUB_URL>Β is the URL you just copied.

Then, add, commit, and push the changes into the repository:

bash
git add .
git commit -m "initial commit"
git push

After pushing the changes, you can find the files in your GitHub repository.


Step 2: Configure Build Script

In the package.json of the Medusa backend, add or change a build script for the admin:

json
"scripts": {
  // other scripts
  "build:admin": "medusa-admin build --deployment",
}

Additional Build Options

Aside from --deployment, you can use the following options when building your admin for deployment:

  • --backend or -b: a string specifying the URL of the Medusa backend. The default here is the value of the environment variable MEDUSA_BACKEND_URL. If this options is added, the value you set for MEDUSA_BACKEND_URL in Vercel will no longer have an effect. For example, medusa-admin build --deployment --backend example.com
  • --out-dir or -o: a string specifying a custom path to output the build files to. By default, it will be the build directory. For example, medusa-admin --deployment --out-dir public.
  • --include or -i: a list of strings of paths to files you want to include in the build output. It can be useful if you want to inject files that are relevant to your hosting. For example, medusa-admin --deployment --include 200.html
  • --include-dist or -d: a string specifying the path to copy the files specified in --include to. By default, the files are coopied to the root of the build directory. You can use this option to change that. For example, medusa-admin --deployment --include 200.html --include-dist static.

Step 3: Add Vercel Configurations

In the root directory of the Medusa backend, create a new file vercel.json with the following content:

json
{
  "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}

Step 4: Push Changes to GitHub

After making all the previous changes, push them to GitHub before starting the deployment on Vercel:

bash
git add .
git commit -m "prepare repository for deployment"
git push

Step 5: Deploy to Vercel

This section covers how to deploy the admin, either using the Vercel website or using Vercel’s CLI tool.

Option 1: Using the Vercel Website

This section explains how to deploy the admin using the Vercel website:

  1. Open theΒ Vercel dashboardΒ after logging in.
  2. Click on the β€œAdd New…” button next to the search bar.
  3. Choose Project from the dropdown.
  4. In the new page that opens, find the Git repository that holds your medusa backend and click on the Import button. If you haven’t connected your Vercel account to any Git provider, you must do that first.
  5. In the Configure Project form:
    1. Set the Framework Preset to Vite.
    2. Open the Build and Output Settings collapsible, and set the Build Command to yarn build:admin and the Output Directory to build. If you’ve configured the admin to use a different output directory, then change it to that directory.
    3. Open the Environment Variables collapsible, and add an environment variable with the nameΒ MEDUSA_BACKEND_URLΒ with the value being the URL to your deployed Medusa backend.
    4. You can optionally edit the Project Name.
  6. Once you’re done, click on the β€œDeploy” button.

This will start the deployment of the admin. Once it’s done, you’ll be redirected to the main dashboard of your new project.

:::note

At this point, when you visit the admin, you will face errors related to Cross-Origin Resource Sharing (CORS) while using the admin. Before you start using the admin, follow along theΒ Configure CORS on the Medusa BackendΒ section.

:::

Option 2: Using Vercel’s CLI Tool

This section explains how to deploy the admin using the Vercel CLI tool. You should have the CLI tool installed first, as explained inΒ Vercel’s documentation.

In the directory of your Medusa backend, run the following command to deploy your admin:

bash
vercel --build-env MEDUSA_BACKEND_URL=<YOUR_BACKEND_URL>

WhereΒ <YOUR_BACKEND_URL>Β is the URL of your deployed Medusa backend.

You’ll then be asked to log in if you haven’t already, and to choose the scope to deploy your project to. You can also decide to link the admin to an existing project, or change the project’s name.

When asked, ”In which directory is your code located?”, keep the defaultΒ ./Β and just press Enter.

The project setup will then start. When asked if you want to modify the settings, answerΒ y. You’ll then be asked a series of questions:

  1. β€œWhich settings would you like to overwrite”: select Build Command and Output Directory using the space bar, then press Enter.
  2. β€œWhat's your Build Command?”: enter yarn build:admin.
  3. β€œWhat's your Output Directory?”: enter build.

After that, it will take a couple of minutes for the deployment to finish. The link to the admin will be shown in the final output of the command.

:::note

At this point, when you visit the admin, you will face errors related to Cross-Origin Resource Sharing (CORS) while using the admin. Before you start using the admin, follow along theΒ Configure CORS on the Medusa BackendΒ section.

:::


Step 6: Configure CORS on the Medusa Backend

To send requests to the Medusa backend from the admin dashboard, you must set theΒ ADMIN_CORSΒ environment variable on your backend to the admin’s URL.

:::note

If you want to set a custom domain to your admin dashboard on Vercel, make sure to do it before this step. You can refer to this guide onΒ Vercel’s documentation.

:::

On your Medusa backend, add the following environment variable:

bash
ADMIN_CORS=<ADMIN_URL>

WhereΒ <ADMIN_URL>Β is the URL of your admin dashboard that you just deployed.

Then, restart your Medusa backend. Once the backend is running again, you can use your admin dashboard.


File: docs/content/deployments/admin/index.mdx


hide_table_of_contents: true

import DocCardList from '@theme/DocCardList';
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';

Medusa Admin Deployment Guides

Find in this page guides to deploy your Medusa Admin on different platforms.


File: docs/content/deployments/server/deploying-on-digital-ocean.md


addHowToData: true

Deploy Your Medusa Backend to DigitalOcean Apps

In this document, you'll learn how to deploy your Medusa backend to a DigitalOcean App.

DigitalOcean is a reliable hosting provider that provides different ways to host websites and servers. One way to host a backend is using their DigitalOcean App Platform.

Prerequisites

Medusa Backend

It is assumed that you already have a Medusa backend installed locally. If you don’t, please follow the quickstart guide.

Furthermore, your Medusa backend should be configured to work with PostgreSQL and Redis. You can follow the Configure your Backend documentation to learn how to do that.

Needed Accounts

  • A DigitalOcean account. You need to provide a payment method on sign up.
  • A GitHub account to create a repository to host your Medusa backend’s codebase.

:::tip

If you want to use another Git Provider supported by DigitalOcean, it’s possible to follow along with this guide but you’ll have to perform the equivalent steps in your Git Provider.

:::

Required Tools


Changes to package.json

Change the start script in package.json to the following:

json
"start": "medusa migrations run && medusa start"

This ensures that Migrations are run everytime the Medusa backend is restarted.


Changes to medusa-config.js

In medusa-config.js, the DATABASE_URL variable is set to the environment variable DATABASE_URL. This needs to be changed as DigitalOcean provides the different details of the database connection separately.

Replace the previous declaration of DATABASE_URL in medusa-config.js with the following:

js
const DB_USERNAME = process.env.DB_USERNAME
const DB_PASSWORD = process.env.DB_PASSWORD
const DB_HOST = process.env.DB_HOST
const DB_PORT = process.env.DB_PORT
const DB_DATABASE = process.env.DB_DATABASE

const DATABASE_URL = 
  `postgres://${DB_USERNAME}:${DB_PASSWORD}` + 
  `@${DB_HOST}:${DB_PORT}/${DB_DATABASE}`

In addition, you must add to projectConfig in the exported object a new property database_extra:

js
module.exports = {
  projectConfig: {
    // ...
    database_extra: { ssl: { rejectUnauthorized: false } },
  },
}

Create GitHub Repository

Before you can deploy your Medusa backend you need to create a GitHub repository and push the code base to it.

On GitHub, click the plus icon at the top right, then click New Repository.

You’ll then be redirected to a new page with a form. In the form, enter the Repository Name then scroll down and click Create repository.

Push Code to GitHub Repository

The next step is to push the code to the GitHub repository you just created.

After creating the repository, you’ll be redirected to the repository’s page. On that page, you should see a URL that you can copy to connect your repository to a local directory.

Copy the link. Then, open your terminal in the directory that holds your Medusa backend codebase and run the following commands:

bash
git init
git remote add origin <GITHUB_URL>

Where <GITHUB_URL> is the URL you just copied.

Then, add, commit, and push the changes into the repository:

bash
git add .
git commit -m "initial commit"
git push

After pushing the changes, you can find the files in your GitHub repository.


Deploy to DigitalOcean App

After logging into your account, click on the Create button at the top right, then choose App.

Choose Repository

In the Create App page, choose GitHub from the Service Provider list.

If you haven’t given DigitalOcean access before, click on Manage Access under Source Code. You’ll then be redirected to GitHub to give DigitalOcean access.

Once DigitalOcean have access to your GitHub account, you should see a Repository input. Click on it and search for the repository you created earlier.

Additional inputs will show up to choose the Branch, Source Directory, and Autodeploy options.

If you host your Medusa backend in a monorepo, you should change the Source Directory to the directory the backend is available in the repository. Otherwise, it can be left as is.

Once you’re done, click Next to move on to the next step.

Specify Web Service Resources

In the next step, you’ll see the resources to create.

If you have a Dockerfile available in the backend’s codebase (which is available by default), you’ll have two resources showing. You can remove it by clicking on the trash icon at the right of the resource.

By default, DigitalOcean hosts the web service in a sub-path of the domain name of the created App. To change it to the root of the domain, click on the edit icon at the right of the Web Service resource.

Then, scroll to HTTP Request Routes and expand it by clicking on Edit at its right. Change the value of the Routes input to /.

Once you’re done click Save. You’ll be taken back to the Resources page.

Specify Database Resources

On the same page, expand the Add Resources section, choose Database, then click Add.

In the new page, you’ll be shown a PostgreSQL database to be created. Notice that it’s important to choose a name that you’ll remember as you’ll need the name in next steps. You can leave the name as is if it’s not necessary to change it.

Once you’re done, click Create and Attach. You’ll be redirected back to the previous page with the database added to the resources.

Once you’re done, click Next to move on to the next step.

Set Environment Variables

In this section, you’ll add environment variables that are essential to your Medusa backend.

You should see two ways to add environment variables: Global or specific to the Web Service.

Click Edit on the second row to add environment variables specific to the Web Service. Add the following environment variables:

bash
DB_USERNAME=${db.USERNAME}
DB_PASSWORD=${db.PASSWORD}
DB_HOST=${db.HOSTNAME}
DB_PORT=${db.PORT}
DB_DATABASE=${db.DATABASE}
REDIS_URL=${redis.DATABASE_URL}
JWT_SECRET=secret
COOKIE_SECRET=secret
NPM_CONFIG_PRODUCTION=false
NODE_ENV=production

:::caution

It’s highly recommended to use strong, randomly generated secrets for JWT_SECRET and COOKIE_SECRET.

:::

Notice how for database environment variables you access the values from the database you created earlier db. If you changed the name of the database, you must change db here to the name you supplied to the PostgreSQL database.

Another thing to note here is that you added a REDIS_URL environment variable that uses a redis resource to retrieve the URL. You’ll be creating this resource in a later section.

:::note

If you're using modules that require setting environment variables, make sure to set them here. You can also add them later. For example, if you're using the Redis Event Bus module, you can set the environment variable for it here or use the same REDIS_URL variable. Your module may also require setting up other resources than those explained in this guide so make sure to add them as well.

:::

Once you’re done click Save.

Finalize App

In the next section, you’ll be shown the app info and the region it will be deployed to. You can leave it all as is or make changes if you find it necessary.

Once you’re done, click Next to go to the next step.

In the final step, you can see a review of everything you created. If everything looks good, scroll down and click Create Resource.

Create Redis Resource

While the backend is being deployed, you can create the Redis resource.

Click the Create button at the top right and choose Database from the dropdown.

In the new page under Choose a database engine, choose Redis.

Then, scroll down to the β€œChoose a name” input. Since you used the name redis in the REDIS_URL environment variables, change the value to redis here.

Once you’re done, click on Create Database Cluster.

Attach Redis Database

Once the Redis database is created go back to the App you created earlier by choose Apps in the sidebar then clicking on the App name.

Click at the white Create button at the top right and choose Create/Attach Database.

In the new page, click on the Previously Created DigitalOcean Database radio button. Then, under Database Cluster select the Redis database you just created.

Once you’re done click Attach Database. This will add the Redis database to the list of resources of your App and will trigger a redeploy of the App.


Test your Backend

Once the redeployment is complete, copy the URL of the App which can be found under the App’s name.

Then, go to <YOUR_APP_URL>/store/products. If the deployment was successful, you should receive a JSON response.


Run Commands on Your Backend

To run commands on your backend, you can access the console on the App’s page by choosing the Console tab. This opens a console in your browser where you can run commands on your backend.

For example, you can run the following commands to create a new admin user:

bash
npm install @medusajs/medusa-cli -g
medusa user --email  --password

Make sure to replace and with the credentials you want to give the user.


Add Environment Variables

You’ll likely need to add environment variables later such as Admin Cross-Origin Resource Sharing (CORS) and Store CORS variables.

To add environment variables, on the App’s page click on Settings and choose the Web Service component.

Then, scroll down and find Environment Variables. You can expand the environment variables by clicking Edit on the right. Here, you can edit, add, and remove environment variables.

Once you click Save, the environment variables will be saved and a redeployment will be triggered.


See Also


File: docs/content/deployments/server/deploying-on-heroku.mdx


addHowToData: true

import styles from '../deployment.module.css';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Deploy Your Medusa Backend on Heroku

In this document, you'll learn how to deploy your Medusa backend on Heroku. Heroku is a PaaS (Platform as a Service) that allows you to easily deploy your applications in the cloud.

Alternatively, you can use this button to deploy the Medusa backend to Heroku directly:

Prerequisites

Medusa Backend

It is assumed that you already have a Medusa backend installed locally. If you don’t, please follow the quickstart guide.

Furthermore, your Medusa backend should be configured to work with PostgreSQL and Redis. You can follow the Configure your Backend documentation to learn how to do that.

Needed Accounts

Required Tools


Deploy to Heroku

1. Login to Heroku from your CLI

Before you can create an app with Heroku, you must login with the CLI tool:

bash
heroku login

Depending on your operating system, you must follow either the instructions in your terminal or a page in your browser will open.

2. Create an App with Heroku

In the root directory of your Medusa backend, run the following commands to create an app on Heroku and add it as a remote origin:

bash
heroku create <APP_NAME>
heroku git:remote -a <APP_NAME>

Where <APP_NAME> is the name of the app you'll create. You can use any name you want.

3. Install Postgresql and Redis on Heroku

Medusa requires a Postgres database and a Redis instance to work. You can add those to your Heroku app using Add-ons.

:::note

If you don't have a payment method set up in your Heroku account, you'll be asked to enter your payment details when you try to install these addons.

:::

PostgreSQL

Add a Postgres add-on to your Heroku app with the following command:

bash
heroku addons:create heroku-postgresql:mini

This uses Heroku Postgres's smallest plan. You can check out the available plans and pricing of Heroku Postgres on Heroku's website.

Redis

Add a Redis instance to your Heroku app with the following command:

bash
heroku addons:create stackhero-redis:ist-ebi1rc

This uses the lowest plan in Stackhero Redis. You can check out the plans and pricing of Stackhero Redis on Heroku's website.

4. Configure Environment Variables on Heroku

Medusa requires a set of environment variables to be configured. You can learn more about Medusa's configurations in the Configure your Medusa backend document.

Run the following commands in the root directory of your Medusa backend to set some environment variables:

bash
heroku config:set NODE_ENV=production
heroku config:set JWT_SECRET=your-super-secret
heroku config:set COOKIE_SECRET=your-super-secret-pt2
heroku config:set NPM_CONFIG_PRODUCTION=false

:::tip

Make sure to replace your-super-secret and your-super-secret-pt2 with actual secrets in a production environment.

:::

Set Buildpack

Additionally, you need to set the buildpack to Node.js using the following command:

bash
heroku buildpacks:set heroku/nodejs

Configure the Redis URL

Stackhero Redis adds the Redis URL under the environment variable STACKHERO_REDIS_URL_TLS. However, Medusa looks for the REDIS_URL environment variable when initializing the connection with Redis.

Retrieve the value of STACKHERO_REDIS_URL_TLS with the following command:

bash
heroku config:get STACKHERO_REDIS_URL_TLS

This prints the value of the environment variable which is a Redis connection string.

Copy that value and use it to set the environment variable REDIS_URL with the following command:

bash
heroku config:set REDIS_URL=<YOUR_REDIS_URL>

Where <YOUR_REDIS_URL> is the value you received from the previous command.

Configure the PostgreSQL Database URL

If you're using the Heroku PostgreSQL Add-on, it should configure the environment variable DATABASE_URL. In that case, you don't need to perform any additional actions.

However, if you use another add-on, make sure to set the environment variable DATABASE_URL to the PostgreSQL Database URL.

(Optional) Configure Modules Environment Variables

If you use in your Medusa backend modules that require setting environment variables, then you should set them at this point.

For example, if you use the Redis Event Bus module:

bash
heroku config:set EVENT_REDIS_URL=<YOUR_REDIS_URL>

Make sure to change EVENT_REDIS_URL to the environment variable name you use for your module's configurations.

If your module requires setting up other services, do that then add the environment variables.

(Optional) Configure CORS Variables

Optionally, if you've deployed the admin dashboard and you want to ensure it can use the backend's REST APIs, you must set the following environment variable:

bash
heroku config:set ADMIN_CORS=<YOUR_ADMIN_URL>

Where <YOUR_ADMIN_URL> is the URL of your admin dashboard.

Similarly, if you've deployed the storefront and you want to ensure it can use the backend's REST APIs, you must set the following environment variable:

bash
heroku config:set STORE_CORS=<YOUR_STOREFRONT_URL>

Where <YOUR_STOREFRONT_URL> is the URL of your storefront.

5. Configure Medusa Backend

Before jumping into the deployment, you need to configure your Medusa backend to ensure it uses the previous environment variables and the recommended production configurations.

medusa-config.js

Update module.exports to include the following configurations:

js
module.exports = {
  projectConfig: {
    redis_url: REDIS_URL,
    database_url: DATABASE_URL,
    database_type: "postgres",
    store_cors: STORE_CORS,
    admin_cors: ADMIN_CORS,
    database_extra:
      process.env.NODE_ENV !== "development"
        ? { ssl: { rejectUnauthorized: false } }
        : {},
  },
  plugins,
}

package.json

Update scripts to include the following scripts:

json
"scripts": {
    "serve": "medusa start",
    "start": "medusa develop",
    "heroku-postbuild": "medusa migrations run",
    "prepare": "npm run build",
    "build": "babel src -d dist --extensions \".ts,.js\""
},

6. Launch your Medusa Backend

Finally, commit and push all changes to Heroku:

bash
git add .
git commit -m "Deploy Medusa Backend on Heroku"
git push heroku HEAD:master

This triggers a redeploy of the Medusa backend with all the new configurations.

Test your Backend

To test your backend, run the following command to retrieve the backend's URL:

bash
heroku apps:info -a <APP_NAME>

Where <APP_NAME> is the name of the app. You should see as the output a bunch of info of the app.

The backend's URL is available under "Web URL". You can copy it and perform requests to it to test it out.

For example, you can send a request to <YOUR_BACKEND_URL>/store/products and you should receive a JSON response with the products in your store.

Troubleshooting: Inspect Build Logs

If an error occurs during the deployment, you can explore your Heroku app build logs using the following command in the root directory of your Medusa backend:

bash
heroku logs -n 500000 --remote heroku --tail -a <APP_NAME>

Where <APP_NAME> is the name of the app.


Run Commands on Your Backend

To run commands on your backend, you can use the following command:

bash
heroku run -a <APP_NAME> -- <COMMAND>

Where <APP_NAME> is the name of the app and <COMMAND> is the command you want to run.

For example, to create an admin user you can run the following command:

bash
heroku run -a <APP_NAME> -- medusa user -e "" -p ""

Where <APP_NAME> is the name of your Heroku app, and and are the credentials you want to use to log in to the Medusa admin dashboard.


Add Environment Variables

You’ll likely need to add environment variables later such as Admin Cross-Origin Resource Sharing (CORS) and Store CORS variables.

To set or change an environment variable's value, you can use the following command:

bash
heroku config:set <ENV_NAME>=<ENV_VALUE> -a <APP_NAME>

Where <APP_NAME> is the name of your Heroku app, <ENV_NAME> is the name of the environment variable, and <ENV_VALUE> is the value.


See Also


File: docs/content/deployments/server/deploying-on-qovery.md


addHowToData: true

Deploy Your Medusa Backend on Qovery

In this document, you'll learn how to deploy your Medusa backend on Qovery with the help of Terraform.

Qovery is a Continuous Deployment Platform that provides you with the developer experience of Heroku on top of your cloud provider (For example, AWS, DigitalOcean).

Terraform is an open source infrastructure as code software (IaC) tool that allows you to easily deploy apps like Medusa and the resources it needs to Qovery using a single script.

:::note

This tutorial explains how to deploy Medusa to a Qovery organization with an AWS cluster. If you want to use a cloud provider other than AWS, you need to make changes to some of the keys and variables used in the tutorial.

:::

Prerequisites

Medusa Backend

It is assumed that you already have a Medusa backend installed locally. If you don’t, please follow the quickstart guide.

Furthermore, your Medusa backend should be configured to work with PostgreSQL and Redis. You can follow the Configure your Backend documentation to learn how to do that.

Needed Accounts

  • A Qovery account with a created organization. Qovery provides a free plan that you can use.
  • An AWS account that you’ll connect to a Qovery cluster.
  • A GitHub account to create a repository to host your backend's codebase.

:::tip

If you want to use another Git Provider supported by Qovery, it’s possible to follow along with this guide but you’ll have to perform the equivalent steps in your Git Provider.

:::

Required Tools


Create GitHub Repository

Before you can deploy your Medusa backend you need to create a GitHub repository and push the code base to it.

On GitHub, click the plus icon at the top right, then click New Repository.

You’ll then be redirected to a new page with a form. In the form, enter the Repository Name then scroll down and click Create repository.

Push Code to GitHub Repository

The next step is to push the code to the GitHub repository you just created.

After creating the repository, you’ll be redirected to the repository’s page. On that page, you should see a URL that you can copy to connect your repository to a local directory.

Copy the link. Then, open your terminal in the directory that holds your Medusa backend codebase and run the following commands:

bash
git init
git remote add origin <GITHUB_URL>

Where <GITHUB_URL> is the URL you just copied.

Then, add, commit, and push the changes into the repository:

bash
git add .
git commit -m "initial commit"
git push

After pushing the changes, you can find the files in your GitHub repository.


Deploy to Qovery

In this section, you’ll learn how to deploy your Medusa backend to Qovery with the help of Terraform.

Sign in Using Qovery CLI

If you haven’t logged in to your Qovery account using the Qovery CLI tool yet, run the following command:

bash
qovery auth

This opens a new page in your browser to log in to Qovery.

Retrieve Qovery Access Token

Terraform needs an access token from Qovery so that it can deploy to your Qovery organization.

Run the following command to retrieve a Qovery access token:

bash
qovery token

You’ll be prompted to choose an organization and add a name and description for the token. Once the command finishes executing, you’ll be given an access token. Save it to use in the next steps.

Add Terraform Variables

You need to add some variables to use for your Medusa deployment to Qovery.

In the root directory of your Medusa backend, create the file variables.tf with the following content:

text
/* Detailed source-code truncated for AI context efficiency. */

This defines the required variables and sets some of them as secret to ensure their values aren’t printed in the console during deployment.

Next, to set the values of these variables, create the file terraform.tfvars with the following content:

bash
qovery_organization_id = ""

# Optional
qovery_create_cluster = true

# Optional
qovery_cluster_id = null

qovery_access_token = ""

# Optional
aws_access_key_id = null

# Optional
aws_secret_access_key = null

# Optional
aws_region = null

# Optional
medusa_jwt_secret = "secret"

# Optional
medusa_cookie_secret = "secret"

git_url = ""

# Optional
git_branch = "master"

# Optional
git_root_path = "/"

Here’s an explanation of each of the variables and how to retrieve their variables:

  • qovery_organization_id: The ID of the Qovery organization to deploy the backend to. It can be found by logging into your Qovery Console. You’ll be redirected to the organization’s main page with a URL of the format https://console.qovery.com/platform/organization/<ORGANIZATION_ID>/projects. Copy the <ORGANIZATION_ID> in the URL to use as the value of this field.
  • qovery_create_cluster: A boolean value indicating whether a new cluster should be created or not. If you already have a cluster that you want to use, you can set the value to false and set the value of qovery_cluster_id. Otherwise, set the value to true and set the values of aws_access_key_id, aws_secret_access_key, and aws_region.
  • qovery_cluster_id: The ID of the existing cluster to use (if qovery_create_cluster is set to false). You can use Qovery’s REST API to retrieve the cluster ID. You can use the token you generated earlier for the Bearer authorization token as explained here.
  • aws_access_key_id, aws_secret_access_key, and aws_region: The credentials used to create the cluster (if qovery_create_cluster is set to true). You can refer to this guide to learn how to retrieve the aws_access_key_id and aws_secret_access_key.
  • medusa_jwt_secret: The value of the JSON Web Token (JWT) Secret on your Medusa backend. It’s recommended to use a strong randomly generated string.
  • medusa_cookie_secret: The value of the Cookie Secret on your Medusa backend. It’s recommended to use a strong randomly generated string.
  • git_url: The URL of the Git repository you created earlier. Make sure it ends with .git.
  • git_branch: The branch to use in the GitHub repo. By default it’s master.
  • git_root_path: The root path of the Medusa backend. By default, it’s /. If you are hosting your Medusa backend in a monorepo in a nested directory, you need to change the value of this variable.

:::note

If you're using modules that require setting up other variables, you can add them here.

:::

Add Terraform Configuration File

In the root directory of your Medusa backend, create the file main.tf with the following content:

text
/* Detailed source-code truncated for AI context efficiency. */

:::note

If you're using modules that require setting up other resources, make sure to add them here.

:::

This is a Terraform configuration file that creates all the resources necessary to deploy Medusa to Qovery. If you set qovery_create_cluster to true, it will create new credentials and a cluster in your Qovery organization using the AWS credentials you set in the variables.

Next, it creates a new project, environment, PostgreSQL database, and a Redis database in your Qovery organization.

Finally, it creates the Medusa app and sets all the necessary environment variables needed to run it.

:::tip

This deployment uses Docker. By default, you should have the files Dockerfile and docker-compose.yml` in the root of your Medusa backend.

:::

Change develop.sh

The Dockerfile runs the file develop.sh to start the backend. Change the content of develop.sh to the following:

bash
#!/bin/bash

# Run migrations to ensure the database is updated
medusa migrations run

# Run backend
medusa start

This makes sure the production backend is started and not a development backend.

Initialize Terraform

In your terminal, run the following command to initialize Terraform:

bash
terraform init

This will install the Qovery Terraform provider and have everything ready before the deployment.

Deploy the Medusa App

Finally, run the following command to deploy your Medusa app:

bash
terraform apply

You’ll be asked to confirm creating all the necessary resources in Qovery. Enter yes and the deployment will start.

The deployment can take up to thirty minutes to finish. You’ll be able to track its status both in your terminal and in the Qovery Console.

:::tip

If you run into any errors while running this command, you can just re-run it after fixing the errors and it will pick up from where it left off. For example, if an error occurred after the creation of the PostgreSQL database, terraform continues from the next task and does not recreate the PostgreSQL database.

:::


Test the Backend

Once the command finishes and the deployment is successful, you can access your backend in the Qovery Console. Go to the project, environment, then the app that you created using Terraform and Qovery. In the app, click the Open button at the top right to open your website in a new tab.

You can access any of the endpoints on your backend using the backend URL. For example, you can get the list of products using the endpoint /store/products.


Run Commands on the Backend

To run commands on the backend, run the following command:

bash
qovery shell

You’ll be asked to either confirm the existing context or choose a new context.

After choosing your Medusa app in the context, you should be able to execute any command in the directory of your Medusa backend. For example, you can run the user command using Medusa’s CLI tool to create a new user:

bash
npm install @medusajs/medusa-cli -g
medusa user --email  --password

Add Environment Variables

You’ll likely need to add environment variables later such as Admin Cross-Origin Resource Sharing (CORS) and Store CORS variables.

To add environment variables, in your Qovery Console go to the Medusa app and choose Environment Variables from the sidebar. You can add environment variables here at any point later on.


See Also


File: docs/content/deployments/server/deploying-on-railway.md


addHowToData: true

Deploy Your Medusa Backend to Railway

In this document, you’ll learn how to deploy your Medusa backend to Railway.

What is Railway

Railway is a hosting provider that you can use to deploy web applications and databases without having to worry about managing the full infrastructure.

Railway provides a free plan that allows you to deploy your Medusa backend along with PostgreSQL and Redis databases. This is useful mainly for development and demo purposes.


Prerequisites

Medusa Backend

It is assumed that you already have a Medusa backend installed locally. If you don’t, please follow theΒ quickstart guide.

Furthermore, your Medusa backend should be configured to work with PostgreSQL and Redis. You can follow theΒ Configure your Backend documentationΒ to learn how to do that.

Needed Accounts

  • AΒ RailwayΒ account.
  • AΒ GitHubΒ account to create a repository to host your backend's codebase.

Required Tools


Changes to Medusa Backend Codebase

By default, Railway looks for a Dockerfile in the root of the codebase. If there is one, it will try to deploy your backend using it.

As this guide doesn't use Docker, make sure to delete Dockerfile from the root of your Medusa backend.


Create GitHub Repository

Before you can deploy your Medusa backend you need to create a GitHub repository and push the code base to it.

On GitHub, click the plus icon at the top right, then click New Repository.

You’ll then be redirected to a new page with a form. In the form, enter the Repository Name then scroll down and click Create repository.

Push Code to GitHub Repository

The next step is to push the code to the GitHub repository you just created.

After creating the repository, you’ll be redirected to the repository’s page. On that page, you should see a URL that you can copy to connect your repository to a local directory.

Copy the link. Then, open your terminal in the directory that holds your Medusa backend codebase and run the following commands:

bash
git init
git remote add origin <GITHUB_URL>

WhereΒ <GITHUB_URL>Β is the URL you just copied.

Then, add, commit, and push the changes into the repository:

bash
git add .
git commit -m "initial commit"
git push

After pushing the changes, you can find the files in your GitHub repository.


Deploy to Railway

In this section, you’ll create the PostgreSQL and Redis databases first, then deploy the backend from the GitHub repository.

Create the PostgreSQL Database

On the Railway dashboard:

  1. Click on the ”New Project**”**Β button.
  2. Choose from the dropdown the ”Provision PostgreSQL” option.

A new database will be created and, after a few seconds, you will be redirected to the project page where you will see the newly-created database.

To find the PostgreSQL database URL which you’ll need later:

  1. Click on the PostgreSQL card.
  2. Choose the Connect tab.
  3. Copy the Postgres Connection URL.

Create the Redis Database

In the same project view:

  1. Click on theΒ NewΒ button.
  2. Choose theΒ DatabaseΒ option.
  3. ChooseΒ Add Redis**.**

A new Redis database will be added to the project view in a few seconds. Click on it to open the database sidebar.

To find the Redis database URL which you’ll need later:

  1. Click on the Redis card.
  2. Choose the Connect tab.
  3. Copy the Redis Connection URL.

Note about Modules

If you use modules that require setting up other resources, make sure to add them at this point. This guide does not cover configurations specific to a module.

Deploy the Medusa Backend Repository

In the same project view:

  1. Click on theΒ New button.
  2. Choose the ”GitHub Repo” option.
  3. Choose the ”Configure GitHub App” option to give Railway permission to read and pull your code from GitHub.
  4. Choose the repository from the GitHub Repo dropdown.

:::tip

If the GitHub repositories in the dropdown are stuck on loading and aren't showing, you might need to delete the project and start over. This only happens before you configure your account with GitHub.

:::

It will take the backend a few minutes to deploy successfully.

Configure Environment Variables

To configure the environment variables of your Medusa backend:

  1. Click on the GitHub repository’s card.
  2. Choose the Variables tab.
  3. Add the following environment variables:
bash
PORT=9000
JWT_SECRET=something
COOKIE_SECRET=something
DATABASE_URL=<YOUR_DATABASE_URL>
REDIS_URL=<YOUR_REDIS_URL>

Where <YOUR_DATABASE_URL> and <YOUR_REDIS_URL> are the URLs you copied earlier when you created the PostgreSQL and Redis databases respectively.

:::warning

It’s highly recommended to use strong, randomly generated secrets forΒ JWT_SECRET and ****COOKIE_SECRET.

:::

Change Start Command

The start command is the command used to run the backend. You’ll change it to run any available migrations, then run the Medusa backend. This way if you create your own migrations or update the Medusa backend, it's guaranteed that these migrations are run first before the backend starts.

To change the start command of your Medusa backend:

  1. Click on the GitHub repository’s card.
  2. Click on the Settings tab and scroll down to the Service section.
  3. Paste the following in the Start Command field:
bash
medusa migrations run && medusa develop

Add Domain Name

The last step is to add a domain name to your Medusa backend. To do that:

  1. Click on the GitHub repository’s card.
  2. Click on the Settings tab and scroll down to the Domains section.
  3. Either click on the Custom Domain button to enter your own domain or the Generate Domain button to generate a random domain.

Test the Backend

Every change you make to the settings redeploys the backend. You can check the Deployments of the backend by clicking on the GitHub repository’s card and choosing the Deployments tab.

After the backend is redeployed successfully, open the app in your browser using the domain name. For example, you can open the URL <YOUR_APP_URL>/store/products which will return the products available on your backend.

:::tip

If you generated a random domain, you can find it by clicking on the GitHub repository’s card β†’ Deployment tab.

:::


Troubleshooting

If you run into any issues or a problem with your deployed backend, you can check the logs in your Railway container instance by:

  1. Click on the GitHub repository’s card.
  2. Click on the Deployments tab.
  3. Click on the View Logs button.

Run Commands on the Backend

To run commands on your backend, you can use Railway’s CLI tool to run a local shell and execute commands.

For example, you can run commands on the backend to seed the database or create a new user using Medusa’s CLI tool.


See Also