Docs Home | Open App

Cloudflare Visit Counter Setup

This project uses a first-party endpoint at /api/visits implemented in functions/api/visits.js.

Why this design

Required Cloudflare configuration

  1. Create a D1 database in Cloudflare (example: image2cpp-visits).
  2. Open Pages project settings and add a D1 binding.
  3. Set binding name to VISITS_DB.
  4. Deploy the project.

Endpoint behavior

On first counted hit, the response sets a cookie marker to reduce duplicate increments from the same browser profile.