Skip to content

fix: Migrate from @cloudflare/next-on-pages to OpenNext #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025

Conversation

nullcoder
Copy link
Owner

Summary

  • Migrate to OpenNext for better Next.js 15 compatibility on Cloudflare Workers
  • Fix API routes that were not working with the previous setup
  • Follow Cloudflare's new recommended approach for Next.js deployments

Changes

  • Replace @cloudflare/next-on-pages with @opennextjs/cloudflare
  • Add open-next.config.ts with R2 incremental cache configuration
  • Update build scripts to use OpenNext CLI
  • Update wrangler.toml to use OpenNext output paths
  • Remove explicit edge runtime export (handled by OpenNext)
  • Add .open-next/ to .gitignore

Test plan

Context

This migration was necessary because:

  1. The previous setup with @cloudflare/next-on-pages wasn't properly handling API routes
  2. Cloudflare now recommends OpenNext for Next.js deployments to Workers
  3. OpenNext provides better compatibility with Next.js 15 features

🤖 Generated with Claude Code

This migration improves Next.js 15 compatibility and Cloudflare Workers integration by switching to the OpenNext framework. Key changes include:

- Replace @cloudflare/next-on-pages with @opennextjs/cloudflare dependency
- Add open-next.config.ts with R2 incremental cache configuration
- Update wrangler.toml to use OpenNext build output paths (.open-next/worker.js and .open-next/assets)
- Modify build scripts to use `npx @opennextjs/cloudflare build`
- Remove explicit edge runtime export as OpenNext handles runtime configuration automatically
- Add .open-next/ to .gitignore for build artifacts

This provides better compatibility with Next.js 15 features and improved performance on Cloudflare Workers.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@nullcoder nullcoder added cloudflare Cloudflare-specific edge-runtime Edge runtime compatibility priority: high Should be done soon needs review Ready for code review labels Jun 5, 2025
Copy link

cloudflare-workers-and-pages bot commented Jun 5, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
ghostpaste 2240a3d Jun 05 2025, 08:48 AM

@nullcoder nullcoder merged commit 2fa4b95 into main Jun 5, 2025
1 check passed
@nullcoder nullcoder deleted the fix/migrate-to-opennext branch June 5, 2025 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cloudflare Cloudflare-specific edge-runtime Edge runtime compatibility needs review Ready for code review priority: high Should be done soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant