Medusa is a Node.js-based, open-source, ecommerce platform. Medusa allows developers to create scalable and sophisticated commerce setups with minimal effort and a positive developer experience. It is an open-source alternative to Shopify with a fantastic developer experience and limitless customization options for merchants looking to scale.
Medusa has essential ecommerce features such as orders, exchanges, returns, and much more. All of these features set Medusa apart from other headless Commerce CMS.
In this tutorial, you’ll learn how to create a video store with Medusa using its Next.js storefront. You’ll be integrating with it Stripe and Algolia.
You can check out the full code in this GitHub repository.
Prerequisites
Before you begin this tutorial, ensure you have the following requirements:
- Node.js version 14 or later.
- A Stripe account.
- An Algolia account.
- (Optional) MinIO is used as a file service plugin with Medusa. If you plan to use it as well, you must have MinIO installed and running.
- Yarn is used throughout this tutorial. You can also use NPM instead.
Create a Medusa Server
With the above requirements, install the Medusa CLI tool by running the command below:
Then, create a Medusa application with the command below:
The above command will prompt you to choose the installation folder for this application. Enter
as the project folder name, selectCopy to clipboardgamestore
as the starter for this project, and selectCopy to clipboardmedusa-starter-default
as the storefront starter to install.Copy to clipboardNext.js Starter
Your selections should look like the ones in the screenshot below:
Now, wait while Medusa creates the necessary folders and files to run the application. Once the installation is completed, Medusa will create three main folders in the
folder:Copy to clipboardgamestore
,Copy to clipboardadmin
, andCopy to clipboardbackend
.Copy to clipboardstorefront
Next, open three different terminal tabs. Change the directory into these folders, and start each part of the application with the following commands. Run each command in its respective terminal simultaneously:
Install Algolia Plugin
Algolia is a search engine service that enables developers to integrate advanced search features such as typo tolerance, recommended results, and quick responses into their websites.
Before you install the plugin, follow the steps here to get your Algolia Application ID, Search-Only API Key, and Admin API Key**.**
Then, install the Algolia plugin by running the command below in your Medusa backend root folder:
And add the following environment variables to your Medusa server:
andCopy to clipboard<YOUR_APP_ID>
are the Application ID and Admin API keys respectively.Copy to clipboard<YOUR_ADMIN_API_KEY>
Finally, in
, add the following item into theCopy to clipboardmedusa-config.js
array:Copy to clipboardplugins
The
are attributes that can be searched in a product, andCopy to clipboardsearchableAttributes
are the product attributes that should be returned in the search result.Copy to clipboardattributesToRetrieve
Install the Stripe Plugin
Stripe is a tested-and-trusted transaction processing platform. Stripe provides you with all of the technical components required to handle transactions safely and the analytical features required to gain insight into your sales.
Install the Stripe Plugin with the command below:
Next, add configurations for your Stripe plugin in the
file:Copy to clipboardbackend/medusa-config.js
Finally, add in the
file yourCopy to clipboardbackend/.env
andCopy to clipboardapi_key
keys to theCopy to clipboardwebhook_secret
andCopy to clipboardSTRIPE_API_KEY
environment variables.Copy to clipboardSTRIPE_WEBHOOK_SECRET
Install File Service Plugin (MinIO)
MinIO is an open-source distributed object storage server written in Go that is intended for private cloud infrastructure and provides S3 storage functionality.
Medusa uses file service plugins to store files such as product images. It’s important to add a file service plugin to create products. You can use MinIO, S3, or DigitalOcean Spaces.
Install the MinIO plugin module with the command below:
Next, open your
file, and add the following credentials:Copy to clipboardbackend/.env
is the URL of your MinIO server,Copy to clipboard<ENDPOINT>
is the name of your MinIO bucket, andCopy to clipboard<BUCKET>
andCopy to clipboard<ACCESS_KEY>
are your access and secret keys.Copy to clipboard<SECRET_KEY>
Finally, add the following configurations to the array of plugins in the
file:Copy to clipboardbackend/medusa-config.js
Add Products Using Medusa Admin
The Medusa Admin is an application connected to the Medusa Server to allow you to manage the data in your applications. Here you’ll add some products to the store from the Medusa admin.
While your Medusa server is running, run the Medusa admin if it’s not already running:
Then, navigate to
to view the Medusa Admin. You'll see the a login screen.Copy to clipboardhttp://localhost:7000
Medusa seeded your database with a demo admin that you can login with. Use the following credentials to login:
- Email: Copy to clipboard
admin@medusa-test.com
- Password: Copy to clipboard
supersecret
Once logged in, you should have access to the Medusa dashboard where you can manage your application content (create products, manage orders, and more).
On the product page, click the “Add New Product” button to add some video game products. You can add as many as you want.
Customize the Next.js Storefront
Now that we have added and created some video games in our admin, let’s customize the storefront to look like a games store application.
To do that, locate the
****directory and modify the following files.Copy to clipboardstorefront
You can download the images used in the storefront here on Github.
with the code snippet below:Copy to clipboardstorefront/src/modules/home/components/featured-products/index.tsx
This changes title of the featured products component as well as some of the text to match the video game concept of our store.
:Copy to clipboardstorefront/src/modules/home/components/hero/index.tsx
This changes the text and image in the hero section of the store.
:Copy to clipboardstorefront/src/modules/layout/components/footer-cta/index.tsx
This changes the text and image in the section right before the footer.
:Copy to clipboardstorefront/src/modules/layout/components/footer-nav/index.tsx
This changes the text in the footer of the storefront.
:Copy to clipboardstorefront/src/modules/store/components/index.tsx
This changes the text in the store page.
:Copy to clipboardstorefront/src/pages/index.tsx
This changes the metadata of the storefront.
Test Storefront
Make sure the Medusa server is still running. Then, run the following command to start the storefront:
Now, navigate to
to preview the products in your Medusa store.Copy to clipboardhttp://localhost:8000
Then click on the Store link in the navigation bar to view the products in the store.
Add Algolia Integration
The Algolia integration is built into the Next.js storefront by default. You only need to take three steps to get it to work.
First, enable the search feature in the
file:Copy to clipboardstore.config.json
Then, add the necessary environment variables in the
file:Copy to clipboard.env.local
Ifis not available, make sure to renameCopy to clipboard.env.local
toCopy to clipboard.env.template
.Copy to clipboard.env.local
andCopy to clipboard<YOUR APP ID>
are the Application ID and Search-Only API Key on the API Keys page on Algolia respectively.Copy to clipboard<YOUR SEARCH API KEY>
Finally, change the code in
to the code snippet below:Copy to clipboardsrc/lib/search-client.ts
If you run your Next.js storefront while the Medusa server is running, the search functionality will be available in your storefront by clicking the search icon in the navigation bar.
Add Stripe Integration
The last step in the tutorial is to integrate Stripe payment to allow customers to pay for their orders during checkout.
To do that, you’ll need to add Stripe to Regions in the Medusa Admin by following the steps below:
- Navigate to Settings > Regions.
- For each region, click the three dots at the top right of the first section on the right.
- Click on Edit Region Details from the dropdown.
- Under the providers section, select Stripe.
- Click Save.
Then in
add the following environment key:Copy to clipboardstorefront/env.local
Where
is your Stripe Publishable Key.Copy to clipboard<YOUR_PUBLISHABLE_KEY>
Test Stripe
Restart your Next.js storefront and make sure the Medusa server is still running. Then, try adding some products to the cart and proceed to checkout.
On checkout, in the Payment section you’ll be able to use Stripe to pay for the order.
Conclusion
Throughout this tutorial, you’ve learned how to build a video game store with Medusa. Whether you’re using the Next.js storefront or a storefront of your own, you can integrate other services like Stripe and Algolia using Medusa’s plugin system.
To learn about what more you can do with Medusa, check out Medusa’s documentation for guides on different integrations, API reference, user guide, and much more.
Should you have any issues or questions related to Medusa, then feel free to reach out to the Medusa team via Discord.
Share this post
Try Medusa
Spin up your environment in a few minutes.

You may also like
On this page