Migrating from next-on-pages to open-next

Hello, I am currently upgrading my application from next-on-pages to the open-next one. Do I need to create a new project because it uses workers or can I use pages still? very confused
7 Replies
SuperHelpflare
Support AI
According to the documentation, you can upgrade your existing Next.js application to use OpenNext. You don't necessarily need to create a new project. As stated in the documentation: "You can convert an existing Next.js application to run on Cloudflare" (Source: Deploy an existing Next.js project on Workers) However, please note that OpenNext uses Cloudflare Workers, which is a different environment than Cloudflare Pages. While you can upgrade your existing application, you will need to configure it to work with Workers. You can follow the steps outlined in the documentation to upgrade your application: Deploy an existing Next.js project on Workers If you're still unsure, feel free to ask, and I'll do my best to help you through the process.
This is an AI generated response, it may not be 100% accurate. Please validate the output. You can ask followups by replying to this message or mentioning me.
Kief
KiefOP2w ago
So yes, I would have to delete my pages one and make a new workers one
SuperHelpflare
Support AI
According to the documentation, if you want to deploy your Next.js app to Cloudflare Workers using the OpenNext adapter, you will need to create a new project specifically for Workers. This means you will need to delete your existing Pages project and create a new one for Workers. You can't simply convert an existing Pages project to use Workers. Before deleting your Pages project, make sure to review the steps to delete all deployments in your Pages project, as you may encounter issues if you have a high number of deployments. You can find more information on how to delete all deployments in your Pages project in the Cloudflare documentation. Once you've deleted your Pages project, you can follow the steps to deploy an existing Next.js project on Workers, as outlined in the Cloudflare documentation.
This is an AI generated response, it may not be 100% accurate. Please validate the output. You can ask followups by replying to this message or mentioning me.
Kief
KiefOP2w ago
my worker size is 3.1mb now
SuperHelpflare
Support AI
According to the documentation, the maximum size limit for a Worker on the Workers Free plan is 3 MB after compression. Since your Worker size is 3.1 MB, you are exceeding this limit. You may encounter an allocation error due to the size of your Worker. To resolve this issue, you can consider reducing the size of your Worker bundle. Here are some strategies to reduce the upload size of a Worker, as outlined in the Cloudflare documentation: * Storing configuration files, static assets, and binary data using Workers KV, R2, D1, or Workers Static Assets instead of bundling them within your Worker code. * Splitting functionality across multiple Workers and connecting them using Service bindings. Alternatively, you can consider upgrading to the Workers Paid plan, which allows for a maximum Worker size of 10 MB after compression. Source: https://developers.cloudflare.com/workers/platform/limits/#worker-size
This is an AI generated response, it may not be 100% accurate. Please validate the output. You can ask followups by replying to this message or mentioning me.
Kief
KiefOP2w ago
how can i find out which files are causing the biggest impact in terms of file size
SuperHelpflare
Support AI
According to the documentation, you can use the wrangler command-line tool to assess the size of your Worker bundle after compression. To do this, you can run the following command:
wrangler deploy --outdir bundled/ --dry-run
wrangler deploy --outdir bundled/ --dry-run
This will output the total upload size of your Worker bundle, including the compressed size. The output will resemble the following:
Total Upload: 259.61 KiB / gzip: 47.23 KiB
Total Upload: 259.61 KiB / gzip: 47.23 KiB
This will give you an idea of the overall size of your Worker bundle. To identify which files are contributing the most to the size of your bundle, you can use the wrangler command with the --verbose flag:
wrangler deploy --outdir bundled/ --dry-run --verbose
wrangler deploy --outdir bundled/ --dry-run --verbose
This will output a detailed breakdown of the files in your bundle, including their sizes. You can also use tools like wasm-opt to optimize the size of your WebAssembly binary, if you're using WebAssembly in your Worker. Source: https://developers.cloudflare.com/workers/platform/limits/#worker-size Additionally, you can also use the wrangler command with the --bundle-analyze flag to get a detailed report of the bundle size:
wrangler deploy --outdir bundled/ --dry-run --bundle-analyze
wrangler deploy --outdir bundled/ --dry-run --bundle-analyze
This will output a detailed report of the bundle size, including the size of each file and the total size of the bundle. Source: https://developers.cloudflare.com/workers/cli-wrangler/commands/#deploy
This is an AI generated response, it may not be 100% accurate. Please validate the output. You can ask followups by replying to this message or mentioning me.

Did you find this page helpful?