Skip to content

Repository files navigation

Snack Lab

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

Local development

Install dependencies:

npm clean-install

Create a local Cloudflare vars file for development:

cp .dev.vars.example .dev.vars

Then set your existing admin password in .dev.vars:

ADMIN_PASSWORD=your-existing-password

Start the app:

npm run dev

Cloudflare deployment

In 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_PASSWORD

Use the same password value you already use if you are not rotating it yet.

Required Cloudflare bindings

wrangler.toml expects these bindings:

  • STORE_KV → KV namespace
  • STORE_R2 → R2 bucket
  • ADMIN_PASSWORD → Wrangler secret

Useful commands

npm run dev
npm run build
npm run preview
npm run deploy
npm run lint

What the app does

  • Public storefront with stock-aware cart limits
  • Cash-on-pickup checkout flow
  • Admin inventory management
  • Admin order management and reconciliation
  • Customer item request submission

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages