Using CloudFlare Pages



TL;DR - I love CloudFlare Pages!
I've been excited about this for a while. Now that I've deployed a number of production sites on CloudFlare Pages, I think it's time to write about my key highlights.
Introduction
Normally, taking a preference to AWS, I recommend my customers use CloudFront + S3 for their static sites. Hyper scalable and cost-effective. But what about smaller sites? What if I wanted no cost...
On their website, CloudFlare describes Pages as:
Cloudflare Pages is a JAMstack platform for frontend developers to collaborate and deploy websites.
JAMstack
JAMstack is quickly becoming the new standard architecture for many sites and businesses across the globe. Through the use of modern build tools, pre-rendered content is able to be served by a CDN (CloudFront, CloudFlare, Azure CDN etc) and made dynamic through the use of APIs and/or serverless functions (AWS Lambdas or CloudFlare Workers, are two examples)
Deployment
Deployment to CloudFlare Pages is easy. It's as simple as selecting a repo and the framework, and away it goes. With Cloudflare Pages, they have a very tight integration with GitHub and GitLab. CloudFlare will take care of all CI environments and steps on your behalf.
Serverless
Cloudflare also offers a serverless platform called Cloudflare Workers. You can deploy code (You can write Workers with any language that can compile to JavaScript) on Workers and use it in your Pages site. To extend further, with Workers KV and Durable Objects, you can go beyond stateless functions as well.
On a couple of my sites, I've been able to very quickly create working contact forms, by using a CloudFlare Worker, and deployed either by Wrangler or as a Pages Function (within the /functions directory at the root of my project).
Scalability
CloudFlare is already one of the major players in the CDN industry. Their network places ~95% of the internet-connected population within 50ms of their infrastructure. So when CloudFlare Pages was made GA, surely Pages was built upon this fantastic network? It certainly is!
When I moved my sites over from other providers, I saw a major reduction in TTFB (Time to First Byte). From around 150-175ms to just under 100ms (on average).
Sustainability
That's right - sustainability is becoming more and more prominent. Luckily CloudFlare is a Green Web Foundation partner. This means that the Pages infrastructure is powered by 100% renewable energy.