Cloudflare Docs
Pages
Edit this page
Give us feedback
Set theme to dark (⇧+D)

Setup Pages for a SaaS platform

​​ Background

Learn how to have customers point their domains to your Pages projects for SaaS platforms. This allows customers to use Cloudflare proxying/DNS or an external DNS provider.

​​ Set up

  1. Pick your CNAME target, the record that you want customers to point to. In this guide, our example target will be customers.example.com.

  2. Add your CNAME target to Pages custom domains

    Add your CNAME target to Pages custom domains
  3. Next, to onboard customers to this Pages project, add their custom domain to the project. You can do this over the API or in the UI:

    Add your customers domain to Pages custom domains
  4. With your CNAME target setup, customers can now add a CNAME on their own domains to customers.example.com. Example:

    Example customer record
  5. If you’re handling multiple customers within the same Pages project, you will probably want to serve different content per customer. To do this, within a Pages Function you can check the hostname of the request. Example:

export function onRequest(context) {
// Get the customer domain
const hostname = new URL(context.request.url).hostname;
// Fetch customer details from KV
const details = context.env.KV.get(hostname);
// ... do things with the details (e.g. serving custom content, rewriting HTML, etc.)
}

To onboard further customers repeat steps 3 and 4.