Skip to content

feat: add migrate command to set up OpenNext.js for Existing Next.js apps#1004

Closed
2u841r wants to merge 1 commit into
opennextjs:mainfrom
2u841r:Existing-Next.js-apps-migrate
Closed

feat: add migrate command to set up OpenNext.js for Existing Next.js apps#1004
2u841r wants to merge 1 commit into
opennextjs:mainfrom
2u841r:Existing-Next.js-apps-migrate

Conversation

@2u841r
Copy link
Copy Markdown
Contributor

@2u841r 2u841r commented Nov 24, 2025

This PR introduces a new CLI workflow that automates the 10+ step migration process for existing Next.js applications moving to OpenNext.js for Cloudflare.

What’s included

  • Adds support for:

    npx opennextjs-cloudflare migrate
    
  • Automatically generates or updates all required files for Cloudflare deployment:

    • wrangler.jsonc
    • open-next.config.ts
    • .dev.vars
    • Next.js configuration updates
    • Package.json scripts (dev, deploy, etc.)
  • Detects whether the project uses the Edge runtime and configures accordingly.

  • Provides an interactive package manager selector with keyboard navigation:

    • npm
    • pnpm
    • yarn
    • bun
    • deno
  • Performs a full end-to-end setup with zero manual steps.

Why this is useful

The existing migration guide requires following more than 10 manual steps. This flow automates the entire process, reducing setup time from several minutes to just a few seconds.
It ensures consistency, prevents misconfiguration, and improves the onboarding experience for developers migrating their existing projects.

Notes

  • This PR only affects the CLI workflow and does not change the underlying runtime.
  • Documentation can later include this automated command as the recommended approach for existing app migration.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 24, 2025

🦋 Changeset detected

Latest commit: e7b6473

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

}

// Step 3: Create/update wrangler.jsonc
console.log("⚙️ Creating wrangler.jsonc...");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 "services": [
    {
      "binding": "WORKER_SELF_REFERENCE",
      // The service should match the "name" of your worker
      "service": "my-app",
    },
  ],

missing in templates/wrangler.jsonc
also- comments/explanation only for r2_buckets, not other keys.

while in docs comments for almost all keys/values + "services" key is there.

Copy link
Copy Markdown
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

Definitely a good idea but the implementation needs some work.

(I'll comment further later)

@2u841r
Copy link
Copy Markdown
Contributor Author

2u841r commented Nov 24, 2025

Thanks for the PR.

Definitely a good idea but the implementation needs some work.

(I'll comment further later)


  • Allow edits by maintainers

Thanks for the feedback!
I’ve done everything I could from my side — feel free to adjust or rewrite anything as you think best.

@dario-piotrowicz
Copy link
Copy Markdown
Contributor

Hi @2u841r thank you very much for the PR, I took your changes and expanded on them in #1083. From your previous message it sounded like this would be something you'd be happy with, I really hope you don't mind 🙏

I've made various changes such as updating the command's name from migrate to init (which seemed to be a preferred term from the team).

Please feel free to check 1083 and to put any comments or any feedback you have there 🙏

@dario-piotrowicz
Copy link
Copy Markdown
Contributor

I'm closing this PR as it's being replaced by #1083. Again @2u841r I really hope you don't mind this, your contribution is in any case is very much appreciated (and we hope you'll considering contributing again to the project 😄), so thank you very much! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants