rezasurin / vercel-commerce

Next.js x Medusa

Home Page:https://medusa-nextjs-commerce.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deploy with Vercel

Next.js Commerce x Medusa

Note: Looking for Next.js Commerce v1? View the code, demo, and release notes

A Next.js 13 and App Router-ready ecommerce template, built with Medusa, featuring:

  • Next.js App Router
  • Optimized for SEO using Next.js's Metadata
  • React Server Components (RSCs) and Suspense
  • Route Handlers for mutations
  • Edge runtime
  • New fetching and caching paradigms
  • Dynamic OG images
  • Styling with Tailwind CSS
  • Automatic light/dark mode based on system settings

What is Medusa?

Medusa is a set of commerce modules and tools that allow you to build rich, reliable, and performant commerce applications without reinventing core commerce logic. The modules can be customized and used to build advanced ecommerce stores, marketplaces, or any system that needs foundational commerce primitives. All modules are open-source and freely available on NPM.

Learn more about Medusa’s architecture and commerce modules in Medusa's documentation.

Running locally

You will need to use the environment variables defined in .env.example to run Next.js Commerce. It's recommended to use Vercel Environment Variables for this, but a .env file is all that is necessary.

Note: You should not commit your .env file or it will expose secrets.

1. Install Vercel CLI:

npm i -g vercel

2. Link local instance with Vercel and GitHub accounts (which creates a .vercel directory):

vercel link

3. Download your environment variables:

vercel env pull

4. Install dependencies and run your app:

npm install
npm run dev

Your app should now be running on localhost:3000.

How to configure your Medusa backend for Next.js Commerce

Next.js Commerce x Medusa requires a running Medusa backend.

Prerequisites

Please refer to the documentation to learn about required tools for the Medusa Backend.

How to Install the Medusa Backend

1. Install the Medusa CLI tool:

npm install @medusajs/medusa-cli -g

2. Run the following command to create a Medusa backend:

medusa new my-medusa-store https://github.com/medusajs/medusa-starter-default/tree/nextjs-commerce --seed

3. Start the Medusa backend:

cd my-medusa-store
medusa develop

4. Copy the contents of .env.example to a .env file in the root of your Next.js Commerce project, and make sure the NEXT_PUBLIC_MEDUSA_BACKEND_API environment variable points to your Medusa backend domain (default: http://localhost:9000).

(Optional) Install Medusa Admin plugin and add product categories

Medusa comes with a few demo products, but they won't show up in the template by default. To showcase products in the store, you need to install the Medusa Admin and add a few product categories. To do that:

  1. Install the Medusa Admin plugin
  2. Enable the Product Categories feature flag
  3. Log in to the admin dashboard and create the following product categories:
  • hidden-homepage-carousel
  • hidden-homepage-featured-items
  1. Assign a few products to both categories and they should now show up on the homepage!

About

Next.js x Medusa

https://medusa-nextjs-commerce.vercel.app

License:MIT License


Languages

Language:TypeScript 97.3%Language:JavaScript 2.6%Language:CSS 0.2%