Next.js 向けオンラインストアキット:カタログ、カート、Stripe 決済、注文、配送、クーポン、レビュー、アカウント
インストール
genpm add @core/kit-store含まれるもの
- src/app/(store)/ にソースコード(27 ファイル)。 (57.2 KB)
- src/app/(store)/AGENTS.md に AI ルール、加えて IDE 用のルールファイル。
- .env.example に追加される環境変数: STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, CART_COOKIE_SECRET, ORDER_LINK_SECRET, STORE_CURRENCY。
- @core/cart, @core/catalog, @core/checkout, @core/discounts, @core/kit-cms, @core/orders, @core/reviews, @core/shipping を自動で解決します。
README
このパッケージには README がありません。
これは AI が src/app/(store) で作業するときに読む内容そのものです。それ以外はコンテキストに追加されません。
@core/kit-store — rules for AI agents
Purpose
An online store on top of @core/kit-cms, managed from the same /admin: products with variants and categories,
cart, Stripe Checkout, orders (created only by the Stripe webhook), shipping zones and rates, discount codes,
verified reviews, customer orders page, transactional emails and SEO (Product JSON-LD, sitemap). Every storefront
form is a Next.js Server Action, so it works without JavaScript and never accepts prices from the browser.
Map
_templates/genpm.md— the exact lines this kit adds to the project'ssrc/genpm/*.ts(generated, always current)._lib/maintenance.ts— dailystore.maintenancejob (deletes expired carts).shop/page.tsx,categories/[slug],collections/[slug]— listings.products/[slug]/page.tsx— product page.cart/page.tsx— cart, discount code, shipping country/method, totals and payment.checkout/success— real status.orders/[number]/page.tsx— order for its owner or with the signed email link.account/page.tsx— customer orders.api/stripe/webhook/route.ts— Stripe webhook (@core/stripe)._lib/actions.ts— server actions (add, update, code, shipping, checkout, review)._lib/store.ts— helpers._components/— product card/grid, add to cart,CartLinkfor the header, reviews, order summary,store.css._blocks/products.tsx— "Product grid" and "Buy now" blocks._lib/widgets.ts— sales, orders to ship, low stock._lib/legal.ts+_scripts/seed-legal.ts— legal pages as drafts pending review, with a dashboard warning.
Integration
- @core/kit-cms must be integrated first.
- Env:
STRIPE_SECRET_KEY,STRIPE_WEBHOOK_SECRET,CART_COOKIE_SECRETandORDER_LINK_SECRET(≥ 32 chars),STORE_CURRENCY(e.g.EUR),SITE_URL,EMAIL_FROM. Use Stripe test mode until the end-to-end check passes. If the Stripe MCP server is available and the person agrees, use it to inspect the test account (never live keys). - Migrations for catalog, cart, checkout, orders, shipping, discounts, reviews, comments and stripe.
- Add every line of
_templates/genpm.mdto the project'ssrc/genpm/*.ts(it says which file and where): it createssrc/genpm/commerce.ts(imports that register webhooks, cart steps and the dailystore.maintenancejob), the product sitemap and search sources, theproductGrid/buyNowblocks, and the admin resources and widgets (including comments, where product reviews are moderated). Then run the kit-cmssetup-schedules.tsagain. - Stripe webhook: endpoint
https://<site>/api/stripe/webhookwithcheckout.session.completed,checkout.session.async_payment_succeededandcheckout.session.expired(refunds are started from the admin); locallystripe listen --forward-to localhost:3000/api/stripe/webhook. - Create shipping zones and rates in the admin; put
<CartLink />in the site header and "Shop" in the menu. - The person runs
npx tsx "src/app/(store)/_scripts/seed-legal.ts": terms, shipping, returns/withdrawal, privacy and cookies are created as drafts. They must complete them and have them reviewed before publishing. - Verify in test mode: buy with card 4242 4242 4242 4242, the webhook creates the order, the email arrives, stock decreases, the order page opens from the email link and not without it.
Conventions
- Prices are integers in minor units; the client only sends variant ids, quantities, codes and the shipping choice.
- Orders exist only after Stripe confirms payment (webhook), never from the success page.
- The "before" price is hidden: in the EU it must be the lowest price of the previous 30 days (Omnibus directive).
With @core/pricing installed, show it only through
honestCompareAt.
Don't
- Don't publish legal pages the person has not reviewed, and never present generated legal text as final.
- Don't show fake reviews, ratings, stock counts or countdowns; review JSON-LD only with real approved reviews.
- Don't expose order pages without the owner session or the signed token; don't put tokens in analytics.
# @core/kit-store — rules for AI agents
## Purpose
An online store on top of @core/kit-cms, managed from the same `/admin`: products with variants and categories,
cart, Stripe Checkout, orders (created only by the Stripe webhook), shipping zones and rates, discount codes,
verified reviews, customer orders page, transactional emails and SEO (Product JSON-LD, sitemap). Every storefront
form is a Next.js Server Action, so it works without JavaScript and never accepts prices from the browser.
## Map
- `_templates/genpm.md` — the exact lines this kit adds to the project's `src/genpm/*.ts` (generated, always current).
- `_lib/maintenance.ts` — daily `store.maintenance` job (deletes expired carts).
- `shop/page.tsx`, `categories/[slug]`, `collections/[slug]` — listings. `products/[slug]/page.tsx` — product page.
- `cart/page.tsx` — cart, discount code, shipping country/method, totals and payment. `checkout/success` — real status.
- `orders/[number]/page.tsx` — order for its owner or with the signed email link. `account/page.tsx` — customer orders.
- `api/stripe/webhook/route.ts` — Stripe webhook (@core/stripe).
- `_lib/actions.ts` — server actions (add, update, code, shipping, checkout, review). `_lib/store.ts` — helpers.
- `_components/` — product card/grid, add to cart, `CartLink` for the header, reviews, order summary, `store.css`.
- `_blocks/products.tsx` — "Product grid" and "Buy now" blocks. `_lib/widgets.ts` — sales, orders to ship, low stock.
- `_lib/legal.ts` + `_scripts/seed-legal.ts` — legal pages as drafts pending review, with a dashboard warning.
## Integration
1. @core/kit-cms must be integrated first.
2. Env: `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET`, `CART_COOKIE_SECRET` and `ORDER_LINK_SECRET` (≥ 32 chars),
`STORE_CURRENCY` (e.g. `EUR`), `SITE_URL`, `EMAIL_FROM`. Use Stripe test mode until the end-to-end check passes.
If the Stripe MCP server is available and the person agrees, use it to inspect the test account (never live keys).
3. Migrations for catalog, cart, checkout, orders, shipping, discounts, reviews, comments and stripe.
4. Add every line of `_templates/genpm.md` to the project's `src/genpm/*.ts` (it says which file and where): it creates
`src/genpm/commerce.ts` (imports that register webhooks, cart steps and the daily `store.maintenance` job), the
product sitemap and search sources, the `productGrid` / `buyNow` blocks, and the admin resources and widgets
(including comments, where product reviews are moderated). Then run the kit-cms `setup-schedules.ts` again.
5. Stripe webhook: endpoint `https://<site>/api/stripe/webhook` with `checkout.session.completed`,
`checkout.session.async_payment_succeeded` and `checkout.session.expired` (refunds are started from the admin); locally `stripe listen --forward-to localhost:3000/api/stripe/webhook`.
6. Create shipping zones and rates in the admin; put `<CartLink />` in the site header and "Shop" in the menu.
7. The person runs `npx tsx "src/app/(store)/_scripts/seed-legal.ts"`: terms, shipping, returns/withdrawal, privacy
and cookies are created as drafts. They must complete them and have them reviewed before publishing.
8. Verify in test mode: buy with card 4242 4242 4242 4242, the webhook creates the order, the email arrives, stock
decreases, the order page opens from the email link and not without it.
## Conventions
- Prices are integers in minor units; the client only sends variant ids, quantities, codes and the shipping choice.
- Orders exist only after Stripe confirms payment (webhook), never from the success page.
- The "before" price is hidden: in the EU it must be the lowest price of the previous 30 days (Omnibus directive).
With @core/pricing installed, show it only through `honestCompareAt`.
## Don't
- Don't publish legal pages the person has not reviewed, and never present generated legal text as final.
- Don't show fake reviews, ratings, stock counts or countdowns; review JSON-LD only with real approved reviews.
- Don't expose order pages without the owner session or the signed token; don't put tokens in analytics.
.genpmignore 適用後に組み込まれる正確なツリーです。固定先:
// Selector de variante + cantidad + "Añadir al carrito" (acción de servidor; sin JavaScript).
import type { ProductView } from '@/lib/catalog';
import { addToCart } from '../_lib/actions';
import { price, productPath } from '../_lib/store';
export function AddToCart({ product, compact = false }: { product: ProductView; compact?: boolean }) {
const variants = product.variants.filter((v) => v.active);
const buyable = variants.filter((v) => v.availability !== 'OutOfStock');
const id = `add-${product.id}`;
if (!buyable.length) return <p className="ui-badge ui-badge--warning">Out of stock</p>;
return (
<form action={addToCart} className="store-add" aria-label={`Add ${product.name} to cart`}>
<input type="hidden" name="from" value={productPath(product)} />
{variants.length > 1 ? (
<div className="ui-field">
<label className="ui-field__label" htmlFor={`${id}-variant`}>
Option
</label>
<select id={`${id}-variant`} name="variantId" className="ui-select" defaultValue={buyable[0]!.id}>
{variants.map((v) => (
<option key={v.id} value={v.id} disabled={v.availability === 'OutOfStock'}>
{v.title || v.sku || 'Default'} — {price(v.price)}
{v.availability === 'OutOfStock' ? ' (out of stock)' : v.availability === 'BackOrder' ? ' (backorder)' : ''}
</option>
))}
</select>
</div>
) : (
<input type="hidden" name="variantId" value={buyable[0]!.id} />
)}
{!compact && (
<div className="ui-field">
<label className="ui-field__label" htmlFor={`${id}-qty`}>
Quantity
</label>
<input id={`${id}-qty`} name="quantity" type="number" min={1} max={99} defaultValue={1} className="ui-input store-qty" inputMode="numeric" />
</div>
)}
<button type="submit" className="ui-button ui-button--primary">
Add to cart
</button>
</form>
);
}
このパッケージは MCP サーバーを宣言していません。
| バージョン | コミット | 公開日 | スキャン |
|---|---|---|---|
| 1.0.1 | 6a45dae | 5 時間前 | スキャン合格 |
- genpm
- @core/cart ^1.0.0@core/catalog ^1.0.0@core/checkout ^1.0.0@core/discounts ^1.0.0@core/kit-cms ^1.0.0@core/orders ^1.0.0@core/reviews ^1.0.0@core/shipping ^1.0.0
- 提案
- GenPM は npm コマンドを提案し、あなたが承認した場合にのみ実行します。
- スキャン
- スキャン合格 · 指摘 0 件
- コミット
- v1.0.1 → 6a45dae248ce17fbd95b5f3b2b61c68f66236041 · 取得後に検証済み
- スクリプト
- なし。GenPM はパッケージのコードを実行しません。
- ライセンス
- MIT
- 品質
- 100/100
- 認識されたライセンス達成
- AGENTS.md に目的の説明がある達成
- AGENTS.md に統合手順がある達成
- AGENTS.md に規約や禁止事項がある達成
- テストを含む達成
- セキュリティスキャンに合格達成
- 過去 6 か月以内に公開達成
- 認証済みの公開者達成
- 概要とキーワード達成
- 報告
- 問題を見つけましたか?