Building blocks for digital commerce
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.
- 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
The fastest way to get started is deploying with Medusa Cloud:
- Create a Medusa Cloud account
- Deploy this starter directly from your dashboard
**Prerequisites:
- Node.js v20+
- PostgreSQL v15+
- pnpm v10+
- Clone the repository and install dependencies:
git clone https://github.com/medusajs/b2b-starter.git
cd b2b-starter
pnpm install- Set up environment variables for the backend:
cp apps/backend/.env.template apps/backend/.env- 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- Run migrations:
cd apps/backend
pnpm medusa db:migrate- Add admin user:
cd apps/backend
pnpm medusa user -e [email protected] -p supersecret- Start Medusa backend:
cd apps/backend
pnpm dev-
Open the admin dashboard at
localhost:9000/appand log in. Retrieve your publishable API key at Settings > Publishable API key. -
Set up environment variables for the storefront:
cp apps/storefront/.env.template apps/storefront/.env.local- Update
apps/storefront/.env.localwith your Medusa publishable API key:
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_6c3...- Start storefront:
cd apps/storefront
pnpm devThe storefront runs on http://localhost:8000.
You can slo run the following command from the root to start both backend and storefront:
pnpm dev| 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 |
| 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 |
Licensed under the MIT License.