Many SaaS products eventually get the same request: "Can we use our own domain?" In EventsIQ it is not a nice-to-have. Customers put tracking links in their ads, and those links should say track.theirsite.com , not our name.
This post is how I built it with Next.js and Cloudflare for SaaS. The customer adds one DNS record and never touches a certificate.
The plan in one picture
There are two halves:
The Next.js app does the slow, careful work once: it registers the hostname with Cloudflare, watches the certificate, and writes each campaign's route into Cloudflare KV.
A Cloudflare Worker answers clicks. For each request it reads one KV key, replies with a 302, and queues the click to be saved afterwards.
The Next.js app is never in the path of a click.…