Use ondemand generation of next js in cloudflare pages

Hello,
i want to use OnDemand generation feature of next js in Cloudflare pages.
Can any one guide me on how to do this .
Thanks