A visit does not need a database.
Astro writes the website into static HTML, CSS, JavaScript and assets in dist/. Cloudflare Pages serves those files directly. Reading a page does not query D1 or wait for a client-side application to render.
A signup does.
The /api/* routes invoke Pages Functions. File-based handlers at functions/api/early-access.ts and functions/api/remove.ts access D1 through the DB binding. The static route rule in public/_routes.json limits function invocation to that API path.
Give each part a small responsibility.
- The page
- Make the content readable. Browser TypeScript handles theme preference, navigation, motion, form submission and code copying. Native forms also work without JavaScript.
- The handler
- Validate the request, use prepared SQL statements, and confirm completion only after the database operation succeeds.
- The database
- Keep the registration and its consent record. Enforce unique emails and store a hash of the removal credential.
Cloudflare credentials remain outside browser code. No subscriber-list endpoint is exposed. There is no external form provider or standalone Worker application.
A map back to the source.
src/pages/ The public reading routes
src/components/ Shared interface and SVG artwork
src/content/ Vocabulary, navigation and OpenAPI
src/scripts/ Theme, motion, forms and code copying
functions/api/ Signup and removal handlers
functions/_lib/ HTTP boundaries and hashing
migrations/ The D1 schema
public/ Brand files, headers and routingsrc/content/brand.ts holds shared terminology. The OpenAPI definition lives in src/content/api.ts. Static headers are in public/_headers; API headers are set separately in functions/_lib/http.ts.
Read On the shape of a reward for the current product model. Cloudflare’s Pages Functions documentation describes the hosting platform.