Programmatically create Cloudflare Pages Site, and upload content

I am building a website builder for a specific niche. And I really like Cloudflare Pages. I am thinking that my website builder will generate the static files, HTML, CSS, JS and host them on Cloudflare Pages. The challenge here is how do I create a Site and upload content, all programmatically?

Reading through the docs, I am thinking that maybe I can use Wrangler.

My idea is to put the "publish" work on a Queue. Then the Queue will trigger a worker (not necessarily CF Worker). The worker will fetch and compile the files from the builder. Then it will use Wrangler to create the Site (if it is a new project) and upload the files.

Help me figure this out if this is feasible.

Oh yeah ... one more thing, I also need to be able to attach customer's custom domain to the Site too.

Account ID: 19e9ad6ebb3da377311bc155ecc15134
Was this page helpful?