Skip to content

medusajs/b2b-starter

Repository files navigation

Medusa logo

Medusa B2B Starter

Building blocks for digital commerce

Medusa is released under the MIT license. PRs welcome! Discord Chat Follow @medusajs

Medusa B2B Starter

An official Medusa starter for B2B ecommerce, built with Medusa and Next.js 15. It covers common business-to-business requirements out of the box and is designed to be customized and extended.

Features

  • Company management — Create and manage companies, invite employees, and assign roles
  • Spending limits — Set per-employee spending limits with configurable reset frequencies
  • Approval workflows — Require admin or sales manager approval before orders are placed
  • Quote management — Allow customers and merchants to negotiate quotes with messaging
  • Order editing — Adjust order items, pricing, and totals after placement
  • Bulk add-to-cart — Add multiple products to the cart at once
  • Promotions — Manual and automatic promotion support with free shipping progress
  • Full ecommerce — Products, collections, cart, checkout, and order history

Getting Started

Deploy with Medusa Cloud

The fastest way to get started is deploying with Medusa Cloud:

  1. Create a Medusa Cloud account
  2. Deploy this starter directly from your dashboard

Local Installation

**Prerequisites:

  1. Clone the repository and install dependencies:
git clone https://github.com/medusajs/b2b-starter.git
cd b2b-starter
pnpm install
  1. Set up environment variables for the backend:
cp apps/backend/.env.template apps/backend/.env
  1. Set the database URL in apps/backend.env:
# Replace with actual database URL, make sure the database exists.
DATABASE_URL=postgres://postgres:@localhost:5432/medusa-b2b-starter
  1. Run migrations:
cd apps/backend
pnpm medusa db:migrate
  1. Add admin user:
cd apps/backend
pnpm medusa user -e admin@test.com -p supersecret
  1. Start Medusa backend:
cd apps/backend
pnpm dev
  1. Open the admin dashboard at localhost:9000/app and log in. Retrieve your publishable API key at Settings > Publishable API key.

  2. Set up environment variables for the storefront:

cp apps/storefront/.env.template apps/storefront/.env.local
  1. Update apps/storefront/.env.local with your Medusa publishable API key:
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_6c3...
  1. Start storefront:
cd apps/storefront
pnpm dev

The storefront runs on http://localhost:8000.

You can slo run the following command from the root to start both backend and storefront:

pnpm dev

Configuration

Backend (apps/backend/.env)

Variable Description
DATABASE_URL PostgreSQL connection string
REDIS_URL Redis connection string (optional)
JWT_SECRET Secret used to sign JWT tokens
COOKIE_SECRET Secret used to sign session cookies

Storefront (apps/storefront/.env.local)

Variable Description
NEXT_PUBLIC_MEDUSA_BACKEND_URL URL of the Medusa backend
NEXT_PUBLIC_BASE_URL Public URL of the storefront
NEXT_PUBLIC_DEFAULT_REGION Default region code (e.g. us)
REVALIDATE_SECRET Secret for on-demand cache revalidation

Resources

License

Licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors

Languages