Kit boutique en ligne Next.js : catalogue, panier, paiement Stripe, commandes, livraison, coupons, avis, comptes
Installer
genpm add @core/kit-storeCe que vous obtenez
- Source dans src/app/(store)/, 27 fichiers. (57,2 ko)
- Règles IA dans src/app/(store)/AGENTS.md, plus les fichiers de règles de l’IDE.
- Variables d’environnement ajoutées à .env.example : STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, CART_COOKIE_SECRET, ORDER_LINK_SECRET, STORE_CURRENCY.
- Résout @core/cart, @core/catalog, @core/checkout, @core/discounts, @core/kit-cms, @core/orders, @core/reviews, @core/shipping pour vous.
README
Ce paquet n’a pas de README.
Voici exactement ce que lit votre IA quand elle travaille dans src/app/(store). Rien d’autre n’est ajouté à son contexte.
@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.
L’arborescence exacte qui sera injectée, après .genpmignore. Épinglée à
// Ficha de producto: galería, variantes, precio, stock, descripción, reseñas y JSON-LD Product.
// El precio "antes" no se muestra: en la UE solo puede ser el más bajo de los 30 días previos (Ómnibus);
// con @core/pricing instalado, usa `honestCompareAt` para mostrarlo con garantías.
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { getProduct } from '@/lib/catalog';
import { imageFor } from '@/lib/media';
import { productRating } from '@/lib/reviews';
import { RichText, toPlainText } from '@/lib/rich-text';
import { buildMetadata, jsonLd, jsonLdScript } from '@/lib/seo';
import { AddToCart } from '../../_components/add-to-cart';
import { Reviews } from '../../_components/reviews';
import '../../_components/store.css';
import { one, price, productPath } from '../../_lib/store';
type Props = { params: Promise<{ slug: string }>; searchParams: Promise<Record<string, string | string[] | undefined>> };
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const p = await getProduct((await params).slug);
if (!p) return {};
const img = await imageFor(p.media[0]);
const description = p.seoDescription ?? (p.description ? toPlainText(p.description).slice(0, 160) : undefined);
return (await buildMetadata({ title: p.seoTitle ?? p.name, path: productPath(p), ...(description && { description }), ...(img && { image: img.src }) })) as Metadata;
}
export default async function ProductPage({ params, searchParams }: Props) {
const p = await getProduct((await params).slug);
if (!p) notFound();
const sp = await searchParams;
const [images, rating] = await Promise.all([Promise.all(p.media.slice(0, 8).map((id, i) => imageFor(id, { sizes: i === 0 ? '(min-width: 768px) 50vw, 100vw' : '25vw' }))), productRating(p.id)]);
const gallery = images.filter((i) => i !== null);
const v0 = p.variants.find((v) => v.availability !== 'OutOfStock') ?? p.variants[0];
const error = one(sp.cart_error);
const ld =
v0 &&
jsonLd.product({
name: p.name,
path: productPath(p),
...(p.description && { description: toPlainText(p.description).slice(0, 500) }),
images: gallery.map((g) => g.src),
...(v0.sku && { sku: v0.sku }),
...(p.brand && { brand: p.brand }),
price: v0.price,
availability: v0.availability,
rating: { average: rating.average, count: rating.count },
});
return (
<main className="blk store-product">
<div className="store-product__grid">
<div className="store-gallery">
{gallery.map((img, i) => (
<img key={img.src} {...img} alt={img.alt || (i === 0 ? p.name : '')} loading={i === 0 ? 'eager' : 'lazy'} fetchPriority={i === 0 ? 'high' : undefined} decoding="async" />
))}
</div>
<div>
{p.categories.length > 0 && (
<p className="blog-meta">
{p.categories.map((c, i) => (
<span key={c.slug}>
{i > 0 && ', '}
<a href={`/categories/${c.slug}`}>{c.name}</a>
</span>
))}
</p>
)}
<h1>{p.name}</h1>
{p.priceRange && (
<p className="store-price store-price--big">
{p.priceRange.max.amount > p.priceRange.min.amount ? `${price(p.priceRange.min)} – ${price(p.priceRange.max)}` : price(p.priceRange.min)}
</p>
)}
{rating.count > 0 && (
<p>
<a href="#reviews">
{rating.average.toFixed(1)} out of 5 ({rating.count} reviews)
</a>
</p>
)}
{error && (
<p role="alert" className="ui-alert ui-alert--error">
{error === 'insufficient_stock' ? 'There is not enough stock for that quantity.' : 'This option is not available.'}
</p>
)}
<AddToCart product={p} />
<p className="blog-meta">Shipping costs and delivery times are shown in the cart before payment.</p>
</div>
</div>
{p.description && (
<section aria-labelledby="description-title" className="store-description">
<h2 id="description-title">Description</h2>
<RichText doc={p.description} />
</section>
)}
<Reviews productId={p.id} slug={p.slug} rating={rating} status={one(sp.review)} />
{ld && <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: jsonLdScript(ld) }} />}
</main>
);
}
Ce paquet ne déclare aucun serveur MCP.
| Version | Commit | Publié | Analyse |
|---|---|---|---|
| 1.0.1 | 6a45dae | il y a 3 heures | analyse réussie |
- 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
- proposé
- GenPM propose la commande npm et ne l’exécute que si vous acceptez.
- Utilisé par (1)
- @core/kit-dropshipping ^1.0.0
- analyse
- analyse réussie · 0 problème
- commit
- v1.0.1 → 6a45dae248ce17fbd95b5f3b2b61c68f66236041 · vérifié après téléchargement
- scripts
- Aucun. GenPM n’exécute jamais le code des paquets.
- licence
- MIT
- Qualité
- 100/100
- Licence reconnuevalidé
- AGENTS.md explique son objectifvalidé
- AGENTS.md donne les étapes d’intégrationvalidé
- AGENTS.md liste conventions ou interditsvalidé
- Contient des testsvalidé
- Analyse de sécurité réussievalidé
- Publié au cours des 6 derniers moisvalidé
- Éditeur vérifiévalidé
- Résumé et mots-clésvalidé
- signalement
- Vous avez repéré un problème ?