aurorascharff/next16-commerce
حول
A performant e-commerce demo with Cache Components and Server/Client composition patterns using Next.js 16, React 19, Tailwind CSS and Prisma.
تطوير الويب والتطبيقاتما يمكنك فعله
- Cache Components mix static, cached, and request-time content in the same route. Shared product data uses 'use cache', while cookie-backed cart and saved state use 'use cache: private'.
- Partial Prefetching prefetches the shared route shell. Product links use prefetch={true} so cached product details are available before navigation, while personalized state waits for the visit.
- ensureStatic guarantees static output at the stage a route needs it. The store layout guarantees its shell, product routes guarantee each prefetch, and the About page guarantees a full navigation.
- Server Functions update the cart, saved products, account details, and featured products on the server, then invalidate only the cache tags they change with updateTag.
النمو المقاس للنجوم
- خلال 24 ساعة
- ٠
- خلال 7 أيام
- ٠
- خلال 15 يومًا
- -١
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصلNext.js 16 Commerce
A commerce demo for exploring Cache Components, Partial Prefetching, and static guarantees in Next.js.
This repository started as the demo for my talk, Composition, Caching, and Architecture in Modern Next.js. Since then, the current app has moved to the latest Next.js canary and follows the architecture from the Next.js App Architecture skill and Component Architecture for React Server Components.
Features
- Cache Components mix static, cached, and request-time content in the same route. Shared product data uses
'use cache', while cookie-backed cart and saved state use'use cache: private'. - Partial Prefetching prefetches the shared route shell. Product links use
prefetch={true}so cached product details are available before navigation, while personalized state waits for the visit. ensureStaticguarantees static output at the stage a route needs it. The store layout guarantees its shell, product routes guarantee each prefetch, and the About page guarantees a full navigation.- Server Functions update the cart, saved products, account details, and featured products on the server, then invalidate only the cache tags they change with
updateTag. - React Compiler memoizes components and hooks automatically, so the code needs no manual
useMemooruseCallback. - View Transitions animate personalized content as it streams in from Suspense.
- Async React keeps the interface responsive during server work with
Suspense,useOptimistic,useTransition, anduse.
Original talk branches
starteris the intentionally unoptimized starting point used during the talk.route-groupseparates static and personalized routes with route groups.request-contextencodes request context in the route instead.legacy-talk-demopreserves the demo before the later cart and Next.js 16.4 work.
The main branch is the current version and continues to evolve with Next.js.
Getting started
The app runs on Postgres. Copy .env.sample to .env.local, set DATABASE_URL, then:
pnpm install
pnpm run prisma.push
pnpm run prisma.seed
pnpm run dev
Open http://localhost:3000 in your browser. You can inspect the database with pnpm run prisma.studio.
Run `main` locally with SQLite
Change the datasource provider in prisma/schema.prisma from postgresql to sqlite, then add this to .env.local:
DATABASE_URL="file:./dev.db"
Generate the SQLite client and create the local database:
pnpm exec prisma generate
pnpm run prisma.push
pnpm run prisma.seed
The schema and application code otherwise stay the same.
Testing
The end-to-end tests use @next/playwright with the instant() API to verify the static shell, product prefetches, and personalized state across navigations.
pnpm test:e2e
Static checks:
pnpm lint
pnpm exec tsc --noEmit
Stack
- Next.js canary: App Router, Cache Components, Partial Prefetching,
ensureStatic, and Server Functions - React with React Compiler: Suspense, View Transitions,
useOptimistic, anduse - TypeScript and Tailwind CSS v4
- Prisma on PostgreSQL
- Ariakit for accessible dialogs and popovers
- Playwright with
@next/playwrightfor end-to-end tests
License
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…