appmint-examples/nextjs-store implements a catalog, product detail, and a browser-stored cart with AppEngine pricing. It uses a local fetch transport, not @appmint/js-client. It does not implement customer login, saved-cart synchronization, checkout, or payment confirmation.
Install and configure
git clone https://github.com/JacLight/appmint-examples.git
cd appmint-examples/nextjs-store
cp .env.example .env.local
npm installUse Node 20+ and fill in the ignored server file:
APPENGINE_ENDPOINT=https://appengine.appmint.io
ORG_ID=your-org-id
APP_ID=your-app-id
APP_KEY=your-app-key
APP_SECRET=your-app-secretnpm run devOpen http://localhost:4100. The inspected package declares Next.js ^15.0.0, React ^18.3.1, and scripts dev, build, and start; no test script is defined. Use the checkout's dependency versions, not an unrelated latest scaffold. Keep credentials server-side without NEXT_PUBLIC_ prefixes.
Follow one catalog request
app/page.tsx calls get from lib/appmint.ts. On the server, it calls AppEngine directly, exchanges credentials at profile/app/key, caches application identity in the server module, and sends orgid plus Authorization: Bearer. Product lists have record rows under data; each product's fields are in row.data. Display the returned calculated final price when present.
app/product/[sku]/page.tsx loads one product. These server renders do not read a customer cookie through the generic get helper; they are application-only by default. To personalize catalog pricing, read the current request's session and pass it to viaServer deliberately.
Follow one cart request
components/CartView.tsx is a client component. post chooses a same-origin /api/… request. app/api/[...slug]/route.ts reads appmint_token and supplies it as an argument to viaServer, which sends it upstream as x-client-authorization. The application token and customer token stay separate. The sample reads this cookie but ships no login route to create it.
The proxy currently allows storefront/, profile/customer/, profile/magic-link, affiliate/public/, client/, shipping/, and notice/ prefixes, with GET/POST/PUT/PATCH/DELETE exports. These broad prefixes are demonstration routing, not per-action authorization. Before deployment narrow the allowed method/path pairs, validate request bodies and trusted tenant, and enforce origin/CSRF and session rules on mutations. See the concrete pricing route.
Understand what the cart stores
lib/cart-storage.ts uses appmint.demo.cart in local storage and emits appmint:cart on writes. Lines contain SKU, name, quantity, and a cached unitPrice; the component sends that price with the lines. It never sums those cached values into the displayed cart total. Local storage is browser state, not an AppEngine saved cart.
The component posts productItems, shippingAddress, and couponCode together. Its destination is a fixed Dallas, Texas address. Replace that demo address before offering checkout. Render summary.total, which already contains returned tax and shipping, and inspect valid === false for coupon rejection. On a request failure the component clears the summary rather than inventing a total.
Pricing can create an AppEngine cart ID, but the demo neither retains it as a saved-cart workflow nor calls cart update. The backend also has a line-price fallback when SKU pricing throws; successful HTTP status alone does not prove the basket is valid for payment. Add server item validation and test missing/tampered SKUs before extending checkout.
Verify and build
- Load the catalog and one known product, then request an unknown product separately.
- Add a product, change quantity, apply a controlled coupon, and inspect the same-origin pricing request and returned
total. - Try an invalid coupon and a destination without a usable shipping option after replacing the fixed address.
- Make the backend unavailable and verify you can distinguish the error from an empty catalog. The current catalog can render an error inside its normal page response; UI text alone is not a health check.
- Test two customer sessions and an anonymous request if adding login. Do not share mutable customer-token state between them.
npx tsc --noEmit
npm run build
npm run startstart also uses port 4100; stop the dev process before starting the production build. Check the generated browser bundle and network traffic for accidental credentials. A successful build is not evidence of a completed backend payment.
To extend this app, follow Build a web store, Authentication, and the TypeScript client reference. The SDK reference includes its source-install procedure and current backend route mismatches; it is not a claim that the demo already uses the package.