A modern e‑book storefront built with Next.js App Router, React 19, Tailwind CSS, and TypeScript. It features browsing, cart/checkout (demo), simple auth with JWT, and a clean UI.
- Next.js 15 (App Router)
- React 19
- TypeScript
- Tailwind CSS
- Radix UI + shadcn‑style components
- jose (JWT)
app/ # routes and UI
components/ # UI components
contexts/ # React context providers (auth)
hooks/ # custom hooks
lib/ # utils (auth, db)
public/ # static assets
styles/ # global styles
- Install dependencies
pnpm install
- Run the dev server
pnpm dev
- Open http://localhost:3000 in your browser.
The app uses a JWT secret for signing tokens. Create a .env.local file at the project root:
# Change for production
JWT_SECRET=your-strong-secretIf JWT_SECRET is not set, a default development secret is used.
- Email/password auth with client‑side context stored token.
- Endpoints:
POST /api/auth/signup→ creates user and returns{ user, token }POST /api/auth/login→ verifies credentials and returns{ user, token }GET /api/auth/me→ returns the current user usingAuthorization: Bearer <token>
- Demo admin account (seeded):
- email:
admin@caaqil.com - password:
admin123
- email:
Tokens are stored in localStorage by the auth context for simplicity. For production, prefer HttpOnly cookies.
The default lib/db.ts is an in‑memory store intended for demos. Data resets on server restarts or refreshes during development HMR. Options to persist data:
- Quick: write/read JSON files
- Better DX: Prisma + SQLite
- Production: Hosted DB (Postgres/MySQL/MongoDB)
If you want MongoDB or Prisma wired up, replace lib/db.ts with a real data layer and update API routes accordingly.
pnpm dev– start dev serverpnpm build– build for productionpnpm start– start production serverpnpm lint– run Next lint
- Auth context:
contexts/auth-context.tsx - Auth hooks:
hooks/use-auth.ts - API routes:
app/api/* - Pages:
app/*
Radix and shadcn‑style components are used for accessible, composable UI. Tailwind is configured in postcss.config.mjs and styles.
- This project targets modern Node runtimes compatible with Web Crypto API used in
lib/auth.ts. - Update the seeded admin password only if you change hashing strategy.
- Replace demo assets in
public/with your own.
MIT