尚未检测到更新。GitHub 发布版本后会显示在这里。
个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证正在加载完整 README。 以下为已保存的摘录。
A headless e-commerce storefront that connects Next.js on the frontend to WooCommerce on the backend — delivering the performance and reliability of the world's most popular e-commerce engine.
• What Is This?
• For Business & Product Owners
• For Digital Marketers & Analysts
• For Developers & WooCommerce Specialists
• Quick Start
• Project Structure
• Environment Variables查看完整 README ↗A headless e-commerce storefront that connects Next.js on the frontend to WooCommerce on the backend — delivering the performance and reliability of the world's most popular e-commerce engine.
This is a headless WooCommerce storefront — WooCommerce runs silently in the background managing products, inventory, orders, and shipping, while Next.js powers the entire customer experience: browsing, search, cart, checkout, and order confirmation.
The result: a fast, modern shopping experience without abandoning the WooCommerce ecosystem your team already knows.
Key capabilities at a glance:
| Feature | Implementation |
|---|---|
| Product catalog & search | WooCommerce Store API + ISR |
| Cart & checkout | Zustand + Server Actions + WC Store API |
| Payments | Stripe Checkout + webhook order sync |
| Analytics | Full GA4 Enhanced Ecommerce via GTM |
| Performance | React, ISR, SSG, Next/Image, Web Vitals |
| Testing | Jest + React Testing Library |
| Type safety | TypeScript + Zod |
This project is a modern, headless WooCommerce storefront built with Next.js. It uses React Server Components for product and shop pages, Server Actions for all cart and checkout mutations, and Zustand for state management (cart, checkout, wishlist). All WooCommerce API credentials and Stripe keys remain server-side for security.
Key technical highlights:
Stack: Next.js, React, Zustand, Zod, Stripe, Jest, Tailwind CSS, TypeScript, WooCommerce
Required WordPress plugins: WooCommerce
Variable products: Resolved at the Next.js layer, no theme customization needed
Testing: Jest + React Testing Library
Traditional WooCommerce stores serve every page from PHP — the database query, the HTML render, and the asset delivery all happen on the same server for every visitor. Under load, this creates bottlenecks, and performance degrades directly.
This architecture separates the concerns:
| Concern | Handled by | Benefit |
|---|---|---|
| Product & order data | WooCommerce / WordPress | Familiar admin, existing plugins, no data migration |
| Page delivery | Next.js on CDN edge | Pages served in milliseconds, globally |
| Checkout & payments | Stripe Checkout | PCI-compliant, trusted by customers, handles 3DS |
| Analytics | GTM + GA4 | Full funnel data, no third-party plugin needed |
next/image| Feature | Status |
|---|---|
| Product catalogue with filtering & sorting | ✅ |
| Full-text search | ✅ |
| Variable products (size, colour, etc.) | ✅ |
| Wishlist | ✅ |
| Slide-out cart drawer | ✅ |
| Multi-step checkout | ✅ |
| Live shipping rate calculation | ✅ |
| Stripe payment processing | ✅ |
| Cash on delivery / other WC payment methods | ✅ |
| Order confirmation page | ✅ |
| Dark / light mode | ✅ |
| Mobile-first responsive design | ✅ |
| Schema.org structured data (SEO) | ✅ |
The storefront is stateless — it holds no user data itself. You can run as many instances as needed behind a load balancer. WooCommerce handles inventory and order state. Stripe handles payment state. The frontend scales horizontally with zero configuration.
This storefront ships with a complete GA4 Enhanced Ecommerce implementation out of the box — most e-commerce sites miss half the funnel events or implement them incorrectly. This one does not.
| GA4 Event | When it fires |
|---|---|
view_item_list | Shop/category page loads |
select_item | User clicks a product card |
view_item | Product detail page loads |
add_to_cart | Item added to cart |
remove_from_cart | Item removed from cart |
add_to_wishlist | Item added to wishlist |
view_cart | Cart page / cart drawer opens |
begin_checkout | Checkout page loads |
add_shipping_info | Shipping method selected |
add_payment_info | Payment method selected |
purchase | Order confirmation page loads |
Every event includes the full ecommerce object: item IDs, names, categories, prices, quantities, currency, and the appropriate transaction/list context.
.env controls all tracking — no code changes needed to swap tags or add pixelsdataLayer is initialized in <head> before GTM loads, so zero events are lost during the GTM bootstrapEvery real user session reports LCP, CLS, INP, TTFB, and FCP as GTM events. This means you can segment Core Web Vitals by device, geography, or traffic source directly in GA4 or Looker Studio — no additional tooling needed.
Stripe checkout sessions carry the WooCommerce order ID in metadata, and the WooCommerce order confirmation page fires the GA4 purchase event with the correct revenue, tax, and shipping values — giving your attribution models accurate data.
git clone https://github.com/vakulkin/nextjs-woocommerce.git
cd nextjs-woocommerce
pnpm install
cp .env.example .env.local
Edit .env.local — see Environment Variables below.
pnpm dev
Open http://localhost:3000.
pnpm test
# WordPress / WooCommerce
NEXT_PUBLIC_SITE_URL=https://headless-woocommerce.adsister.com
NEXT_PUBLIC_WOOCOMMERCE_PROTCOL=https
NEXT_PUBLIC_WOOCOMMERCE_HOST=headless.adsister.com
WC_CONSUMER_KEY=ck_...
WC_CONSUMER_SECRET=cs_...
# Stripe
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
# Analytics
NEXT_PUBLIC_GTM_ID=GTM-XXXXXXX
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.