Pages Functions Todo

Same todo app, but the API runs as Pages Functions — no separate Worker needed.

Pages
Static + Functions
KV
Storage
Loading...

Difference from Worker demo

The Worker demo uses a standalone Worker + separate Pages site. This demo puts everything in one Pages project: static files are served normally, and _worker.js handles API routes — all deployed together.

Project structure

afs-pages-fn-demo/
  index.html       # This page (static asset)
  _worker.js       # API handler: /api/todos CRUD (uses env.ASSETS for static)

Deployed with AFS

# Create Pages project with initial deploy
afs exec /cloudflare/pages/.actions/create \
  --name afs-pages-fn-demo --directory /workspace/afs-pages-fn-demo

# Configure KV binding
afs exec /cloudflare/pages/afs-pages-fn-demo/.actions/configure-bindings \
  --kv_namespaces '{"KV":{"namespace_id":"..."}}'

# Redeploy to activate bindings
afs exec /cloudflare/pages/afs-pages-fn-demo/.actions/deploy \
  --directory /workspace/afs-pages-fn-demo