Cloudflare Pages and Subdomains for Users

Hi.

I have a use case that allows users to create their own spaces. Let’s say I have UserA and UserB and they each deployed their space.
I want to use Cloudflare pages to give them serverless pages UserA.example.com and UserB.example.com. Is there a way to automatically do it ?

Currently I was thinking about creating a git branch per user and then adding a DNS record via Cloudflare API but maybe somebody knows another way? I also read about Cloudflare for SaaS but I am not sure it is suitable?