This monorepo serves as a starter template/example for building B2C e-commerce applications using Medusa for e-commerce functionality, Next.js for the frontend, and Sanity for content management.
To get started with this project, follow these steps:
- Clone the repository:
git clone --depth 1 https://github.com/tinloof/medusa-b2c-starter
- Install dependencies:
This project utilizes pnpm for package management and monorepo functionality. To install dependencies using pnpm, execute the following command:
pnpm install
To set up Sanity for your project:
cd
into thefrontend
directory:
cd frontend
- Run the
sanity init
command:
pnpx sanity init --env
-
Make sure to append
NEXT_PUBLIC_
where it makes sense in your.env
file, you can refer to the.env.example
file in thefrontend
directory. -
Set the
NEXT_PUBLIC_SANITY_API_VERSION
in.env
to today's date in the formatYYYY-MM-DD
. -
Get the
SANITY_API_TOKEN
by navigating to the Sanity Manage Dashboard. Choose your project, access the API section, and generate a token with editor permissions.
To set up Medusa for your project:
Once project is deployed
-
Create a Publishable api key in the dashboard settings and set it to
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY
-
Add the URL of the Medusa project to
NEXT_PUBLIC_MEDUSA_BACKEND_URL
After you go through the setup steps, you can run the project using the following command from the root directory:
pnpm dev