Pages functions vs workers - the difference

Difference between Pages Functions and Workers (please correct me if I am wrong):

  • Pages Functions use an older version of Wrangler (version 3.101.0, which cannot be changed). Workers can use the latest version which is 4.x and supports the latest workerd with TLS support.
  • Pages Functions have limited logging; you would need to enable "Log stream" in Pages > Functions to see the logs, versus Workers which has the new "Worker Logs" that you can enable.
  • Pages Functions are not visible in the console under "Workers & Pages" – hence they can only be edited in your Integrated Development Environment.
  • Pages Functions use onRequest(context) and Cloudflare Workers use fetch(request, env, ctx) – I am not sure if they are interchangeable and which is better.
  • Pages Functions have automatic routes based on your /functions folder and have a built-in catch-all routes functionality.
  • Pages Functions and Workers plans are separate from Pages Plans. So even if you have a Pro Pages plan, that still gives you 10 milliseconds of function run time as opposed to 30 seconds (I am not clear about this one).
  • When you make changes to a Pages Function in your Integrated Development Environment, you need to push your entire repository (including your static website, along with your functions folder) to GitHub, and Pages will build it for you. You cannot push one Pages Function only, versus Workers, which can be pushed separately without needing to rebuild your project.
  • Pages Functions are automatically added to your existing domain and project, i.e., www.mysite.com/api/someFunction will just work. Versus a Worker will need some heavy lifting if you want it on the same domain and work alongside your other Pages Functions – I need clarity on this.
  • Rumor: Pages itself may be deprecated, moved, or renamed (may be hyperbole) but it feels like it.
I will keep this updated mostly for my reference. Hoping @Walshy can comment.
Was this page helpful?