NavigationContentFooter
Jump toSuggest an edit

Getting started with MedusaJS

Reviewed on 20 May 2024Published on 10 May 2023
  • ecommerce
  • shopping
  • medusajs

MedusaJS is a headless e-commerce platform built on Node.js and React that allows you to create scalable and powerful e-commerce solutions for your business. The platform is a powerful and adaptable tool that offers a range of customization and integration, as well as extensibility features.

This tutorial will show you how to install and use MedusaJS, create a new project, start the development server, and customize your project.

Before you start

To complete the actions presented below, you must have:

  • A Scaleway account logged into the console
  • Owner status or IAM permissions allowing you to perform actions in the intended Organization
  • An SSH key
  • An Instance running on Ubuntu 22.04 or later
  • Installed PostgreSQL on the Instance

Installing MedusaJS

  1. Log into your Instance using SSH.

  2. Update the APT package cache and upgrade the software already installed on your Instance to the latest version available in Ubuntu’s repository.

    apt update && apt upgrade -y
  3. Prepare your system by adding the Node.js repositories to your APT package manager.

    apt update
    apt install -y ca-certificates curl gnupg
    mkdir -p /etc/apt/keyrings
    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
    echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
  4. Update the APT cache and install the required packages for Medusa:

    apt update && apt install nodejs git
  5. Install the Medusa command line interface using the following command:

    npx create-medusa-app@latest
  6. Run the following command to create a Medusa app:

    yarn create medusa-app
  7. Name your project. This name creates the directory for your Medusa backend. You can choose the default my-medusa-store or use a different name.

  8. Set an admin email for your user account, used later for dashboard access. Choose the default admin@medusa-test.com or another email address.

  9. Decide whether to install the Next.js starter storefront with your Medusa backend. It will install in the <PROJECT_NAME>-storefront directory, where <PROJECT_NAME> is your chosen project name from step 2. Type y and enter to install, or press enter to skip with the default N.

    Tip

    The storefront can be installed later if needed. Medusa, being a headless backend, functions without a storefront by default and allows for any storefront connection. While the Next.js Starter storefront is a solid choice, you also have the option to create your own storefront in the future.

  10. Configure your PostgreSQL connection. This command initially attempts to connect to your PostgreSQL server using default credentials. If unsuccessful, you need to input your PostgreSQL database and password. A successful connection lets you proceed to the next step. These credentials are for creating and configuring a database for your Medusa backend during setup.

After setting up, the Medusa backend launches and opens the admin dashboard in your browser (http://<your-instance-ip>:8000/). You need to set a password for your admin email and provide additional account details. Once logged in, you can begin using Medusa to create your first product and order.

Customizing your project

Inside the project’s root directory, specified at the start of the installation process, you find the following directory structure:

/my-medusa-store
/backend // Medusa backend
/storefront // Medusa storefront starter

You can edit the files to adapt them to your requirements. For instance, if you wish to make changes to the homepage of your MedusaJS application, you can modify the my-medusa-store/storefront/src/pages/index.tsx file.

This particular file comprises the components used for rendering your application’s homepage. If you want to make changes to the backend of your application, you can edit the files in the my-medusa-store/backend to your specific requirements.

MedusaJS comes with a built-in SQLite database for development and testing purposes. However, if you want to deploy your application to production, the use of a PostgreSQL such as a Managed Database for PostgreSQL is highly recommended.

The tool is designed to be customized to your specific needs, and a wide section of Medusa Modules is available to be integrated into your application. For more information on how to configure MedusaJS, refer to the official Medusa documentation and the Medusa development documentation.

Docs APIScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCarreer
© 2023-2024 – Scaleway