Astro电商启动器

astro-medusa-starter — Astro 电商模板

作者 digity-studio

基于 Astro 与 Medusa v2 的开源电商店面启动器,采用静态优先与 React 岛屿架构,部署到 Cloudflare Workers,支持多区域路由与 Stripe 结账。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

3 个预览视图
桌面端首页1 / 3
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 3

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-03查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

静态优先:商品列表、详情与落地页在构建时生成,交互部分以 React 岛屿按需加载

02

Medusa webhook 触发重新部署,使静态页面与商品数据保持同步

03

商品变体库存在客户端加载时刷新,降低静态页面显示过期库存的风险

04

URL 以国家代码为前缀,通过 Medusa region 解析定价、货币与配送选项

05

购物车状态使用 Nanostores 与 localStorage 在客户端持久化

06

部署目标为 Cloudflare Workers,构建产物面向边缘运行

模板详细介绍

这是一个面向电商场景的 Astro 店面启动器,后端对接 Medusa v2,支付通过 Stripe 完成。项目采用静态优先架构:商品列表、商品详情与落地页在构建时生成静态 HTML,购物车、导航和结账流程以 React 岛屿形式按需水合。Medusa 的 webhook 可在商品增删改时触发重新部署,以保持静态页面与后端数据同步;商品变体的库存状态则在客户端加载时刷新,避免静态页面显示过期库存。

路由以 ISO 两位国家代码作为前缀,例如 /:country/store 与 /:country/checkout,国家代码驱动定价、货币与可选配送方式,这些由 Medusa 的 region 配置解析。中间件负责区域识别与基于国家的路由。购物车状态通过 Nanostores 与 localStorage 在客户端持久化。

项目使用 Tailwind CSS 处理样式,表单校验依赖 React Hook Form 与 Zod。部署目标为 Cloudflare Workers,构建产物面向边缘运行。仓库采用 MIT 许可,免费范围限于该版本代码本身;演示图片、字体、图标等第三方素材需单独核对许可,域名、托管、数据库、支付等外部服务可能另外收费。使用前需要有一个运行中的 Medusa v2 后端,并配置 CORS 允许店面来源的请求。

Astro电商启动器

适合你的项目吗?

适用场景

  • 需要以 Astro 构建静态优先电商店面并接入 Medusa v2 后端的项目
  • 希望按国家或区域提供差异化定价、货币与配送选项的跨境店铺
  • 计划将店面部署到 Cloudflare Workers 并利用边缘分发的团队
  • 需要 Stripe 结账与多步骤结算流程(地址、配送、支付)的电商站点

适合人群

  • 已有或愿意搭建 Medusa v2 后端的开发者
  • 熟悉 Astro、React 与 Tailwind CSS 的前端团队
  • 需要多区域路由与区域化定价的电商项目
  • 接受以静态生成加客户端水合方式构建店面的技术团队

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    需要 Node.js 18+ 与 Yarn 4.x,并准备一个运行中的 Medusa v2 后端

  2. 2

    复制 .env.example 为 .env,填写 Medusa 后端地址、发布密钥、默认区域与 Stripe 密钥等变量

  3. 3

    确保 Medusa 后端已配置 CORS,允许店面来源的请求

  4. 4

    开发使用 yarn dev(localhost:8000),生产构建使用 yarn build,本地预览使用 yarn preview

  5. 5

    仓库为 MIT 许可,但演示图片、字体、图标等第三方素材需按各自许可单独核对

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发该版本代码。
  • 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 使用前必须自行搭建并运行 Medusa v2 后端服务,项目本身不包含后端。
  • 结账支付依赖 Stripe 账户,需自行注册并配置密钥,可能产生第三方费用。
  • 需在 .env 中填写 Medusa 发布密钥等环境变量,缺少则无法连接后端。
  • 需配置 Stripe 密钥才能完成支付流程。
  • 配送点选择依赖 InPost GeoWidget,需申请并填写其令牌,属外部服务。
  • 商品图片等资源需自备 S3 存储桶并配置域名,托管可能产生费用。
  • 必须自行在 Medusa 后端配置 CORS 允许店面来源,否则请求会被拒绝。
  • 静态页面同步依赖 Medusa webhook 触发重新部署,需自行配置该集成。
  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

A running [Medusa v2](https://docs.medusajs.com) backend

README 原文

[Stripe](https://stripe.com) account (for payments)

README 原文

PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_...

README 原文

PUBLIC_STRIPE_KEY=pk_test_...

README 原文

PUBLIC_INPOST_GEOWIDGET_TOKEN=your-token

README 原文

S3_DOMAIN=your-bucket.s3.us-east-1.amazonaws.com

README 原文

Make sure your Medusa backend has [CORS configured](https://docs.medusajs.com/learn/configurations/medusa-config#httpstorecors) to allow requests from your storefront origin.

README 原文

Medusa webhooks trigger a re-deploy when products are created, updated, or deleted

README 原文
https://github.com/digity-studio/astro-medusa-starter/blob/main/LICENSEhttps://github.com/digity-studio/astro-medusa-starter/blob/main/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-03。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
Astro Themes
资料与维护参考分
资料较完整 · 96 / 100
技术栈
Astro
网站类型
电商 · 启动器
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2026-09-28
截图检查日期
2026-10-03

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Astro。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

审核声明: [email protected] · 2026-10-04

查看当时使用的来源资料

SHA-256: 3bfc945078bb806960fd025c0d3f682186f5a642cfab6ef0e19ff8e4ba6df41d

2026-10-03T15:39:56.159Z

来源文件 / 仓库
# Astro Medusa Storefront

A blazing-fast, open-source ecommerce storefront built with **Astro**, **React**, and **Medusa v2** — deployed to the edge on **Cloudflare Workers**.

Static-first architecture. Interactive where it matters. Zero compromise on performance.

## Tech Stack

| Layer      | Technology                                                                               |
| ---------- | ---------------------------------------------------------------------------------------- |
| Framework  | [Astro 6](https://astro.build) — static HTML, islands of interactivity                   |
| UI         | [React 19](https://react.dev) — only where you need it                                   |
| Styling    | [Tailwind CSS v4](https://tailwindcss.com) — zero-config Vite plugin                     |
| Backend    | [Medusa v2](https://medusajs.com) — headless commerce engine                             |
| Payments   | [Stripe](https://stripe.com) — secure checkout                                           |
| State      | [Nanostores](https://github.com/nanostores/nanostores) — tiny, framework-agnostic stores |
| Forms      | [React Hook Form](https://react-hook-form.com) + [Zod](https://zod.dev) validation       |
| Deployment | [Cloudflare Workers](https://workers.cloudflare.com) — edge-first                        |

## Architecture

```
┌─────────────────────────────────────────────────┐
│                Cloudflare Workers                │
│                                                 │
│   ┌──────────┐  ┌──────────┐  ┌──────────────┐  │
│   │  Static  │  │  Astro   │  │    React     │  │
│   │   HTML   │──│Middleware│──│   Islands    │  │
│   │  (SSG)   │  │ (Region) │  │ (Cart, Nav)  │  │
│   └──────────┘  └──────────┘  └──────┬───────┘  │
│                                       │         │
└───────────────────────────────────────┼─────────┘
                                        │
                              ┌─────────▼─────────┐
                              │   Medusa v2 API   │
                              │  (Your backend)   │
                              └─────────┬─────────┘
                                        │
                              ┌─────────▼─────────┐
                              │      Stripe       │
                              └───────────────────┘
```

**Static where possible, dynamic where necessary:**

- Product pages, store listing, and landing page are statically generated at build time
- Medusa webhooks trigger a re-deploy when products are created, updated, or deleted — keeping static pages in sync
- Product variant availability is refreshed client-side to prevent stale inventory data
- Cart, checkout, and navigation hydrate as interactive React islands
- Middleware handles region detection and country-based routing
- Cart state persists client-side via Nanostores + `localStorage`

## Pages

| Route                        | Description                                      |
| ---------------------------- | ------------------------------------------------ |
| `/:country/`                 | Landing page                                     |
| `/:country/store`            | Product catalog                                  |
| `/:country/store/:productId` | Product detail with image carousel               |
| `/:country/cart`             | Shopping cart                                    |
| `/:country/checkout`         | Multi-step checkout (address, shipping, payment) |
| `/:country/order/confirmed`  | Order confirmation                               |

All routes are prefixed with an ISO-2 country code for region-based pricing and shipping.

## Getting Started

### Prerequisites

- [Node.js](https://nodejs.org) 18+
- [Yarn](https://yarnpkg.com) 4.x
- A running [Medusa v2](https://docs.medusajs.com) backend
- [Stripe](https://stripe.com) account (for payments)

### Setup

```bash
# Clone the repo
git clone https://github.com/bystrol/astro-medusa-starter.git
cd astro-medusa-starter/

# Install dependencies
yarn

# Configure environment
cp .env.example .env
```

Fill in your `.env`:

```env
PUBLIC_MEDUSA_BACKEND_URL=http://localhost:9000
PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_...
DEFAULT_REGION=us
PUBLIC_STRIPE_KEY=pk_test_...
S3_DOMAIN=your-bucket.s3.us-east-1.amazonaws.com
PUBLIC_INPOST_GEOWIDGET_TOKEN=your-token
PUBLIC_INPOST_SANDBOX=true
```

> Make sure your Medusa backend has [CORS configured](https://docs.medusajs.com/learn/configurations/medusa-config#httpstorecors) to allow requests from your storefront origin.

### Development

```bash
yarn dev        # Start dev server on localhost:8000
```

### Production

```bash
yarn build      # Build for Cloudflare Workers
yarn preview    # Preview the production build locally
```

## Project Structure

```
src/
├── assets/              # Static assets (images, fonts)
├── components/          # Shared UI components
├── layouts/             # Page layouts
├── lib/
│   ├── sdk.ts           # Medusa SDK singleton
│   ├── stores/          # Nanostores (cart state)
│   ├── params/          # Static path generation
│   └── utils/           # Helpers (pricing, stock, etc.)
├── loaders/             # Astro content loaders
├── middleware.ts         # Region detection & routing
├── modules/
│   ├── cart/            # Cart page & sidebar
│   ├── checkout/        # Multi-step checkout flow
│   ├── layout/          # Nav, footer
│   ├── order/           # Order confirmation
│   └── products/        # Product cards, detail, carousel
├── pages/
│   └── [countryCode]/   # All routes, region-prefixed
├── styles/              # Global styles & Tailwind theme
└── types/               # TypeScript type definitions
```

## Key Design Decisions

- **Islands architecture** — React only loads for interactive components (cart, nav, checkout). Everything else ships as zero-JS static HTML.
- **Real-time inventory checks** — Product variant stock data is fetched client-side on page load, ensuring accurate availability even though pages are statically generated.
- **Edge deployment** — Cloudflare Workers adapter means your storefront runs close to your customers, everywhere.
- **Tailwind v4** — No config file. Theme customization lives in CSS with `@theme`. Powered by the Vite plugin.
- **Region-aware routing** — Country code in the URL drives pricing, currency, and available shipping options — all resolved via Medusa regions.

## License

[MIT](LICENSE)

## Author

**Michal Bystryk** — [digity.studio](https://digity.studio/) · [LinkedIn](https://www.linkedin.com/in/michal-bystryk/)

## Work with me

Need a custom storefront, a Medusa integration, or help shipping an ecommerce project?
I build them at **[digity.studio](https://digity.studio/)** — get in touch.
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。