Diátaxis: how-to
Snack Lab is a small Next.js storefront deployed to Cloudflare Workers with OpenNext. It uses:
- KV for products, orders, and item requests
- R2 for uploaded product images
- HTTP-only cookie auth for the admin area
Install dependencies:
npm clean-installCreate a local Cloudflare vars file for development:
cp .dev.vars.example .dev.varsThen set your existing admin password in .dev.vars:
ADMIN_PASSWORD=your-existing-passwordStart the app:
npm run devIn the Cloudflare dashboard, use these commands:
- Build command:
npx opennextjs-cloudflare build - Deploy command:
npx wrangler deploy - Non-production branch deploy command:
npx wrangler versions upload
Before deploying, store the admin password as a Wrangler secret:
npx wrangler secret put ADMIN_PASSWORDUse the same password value you already use if you are not rotating it yet.
wrangler.toml expects these bindings:
STORE_KV→ KV namespaceSTORE_R2→ R2 bucketADMIN_PASSWORD→ Wrangler secret
npm run dev
npm run build
npm run preview
npm run deploy
npm run lint- Public storefront with stock-aware cart limits
- Cash-on-pickup checkout flow
- Admin inventory management
- Admin order management and reconciliation
- Customer item request submission