What is the code size limit for deploying a Next.js project using "Pages"?

I deployed a Next.js project using "Pages", and the build was successful. However, I'm getting a 500 error when I try to access the site. I'm not sure if this is related to the size of my codebase.
8 Replies
Chaika
Chaika4mo ago
It would fail on deploy if it was size related. Tail your function and look at the logs ?pages-logs
SuperHelpflare
SuperHelpflare4mo ago
If you're looking to tail a Pages Function you can do so in the UI here: https://dash.cloudflare.com?to=/:account/pages/view/:pages-project/:pages-deployment/functions or with Wrangler: wrangler pages deployment tail [deploymentId/url]
shiki
shikiOP4mo ago
Oh yes, thanks for your reminder, I saw the error:"message": [ "Error: No such module "next-on-pages-dist/functions/src/async_hooks".\n imported from "next-on-pages-dist/functions/src/middleware.func.js"" ]
Chaika
Chaika4mo ago
Sounds like you're missing the compat flag nodejs_compat
Chaika
Chaika4mo ago
The quick start of the package covers that: https://www.npmjs.com/package/@cloudflare/next-on-pages This section in specific
Go to the Pages project settings page (Settings > Functions > Compatibility Flags), add the nodejs_compat flag for both production and preview, and make sure that the Compatibility Date for both production and preview is set to at least 2022-11-30.
npm
@cloudflare/next-on-pages
@cloudflare/next-on-pages is a CLI tool that you can use to build and develop Next.js applications so that they can run on the Cloudflare Pages platform (and integrate with Cloudflare's various oth. Latest version: 1.13.12, last published: 2 months ago. Start using @cloudflare/next-on-pag...
shiki
shikiOP4mo ago
This is my current configuration, but it's still throwing an error. I asked Gemini 2.5 Pro, and it said that next-intl is incompatible with pages.
No description
Chaika
Chaika4mo ago
For the compat flag to work you need to do another deploy
shiki
shikiOP4mo ago
This isn't a new configuration; I set it up when I created these pages. I solved this problem by updating to the latest version, 2025-05-05.

Did you find this page helpful?