Interactive CLI/TUI tool for setting up and configuring OpenNext.js projects for Cloudflare Workers (AWS + Netlify coming soon)
Quick Start β’ Packages β’ Documentation β’ Development
OpenNext.js CLI is a comprehensive, interactive command-line tool that simplifies setting up and managing OpenNext.js projects for Cloudflare Workers. Built with modern UX principles using @clack/prompts (same as next-forge), it provides a beautiful, intuitive interface for project setup, configuration, deployment, and maintenance.
OpenNext.js is an open-source adapter that enables deploying Next.js applications to various platforms, including Cloudflare Workers. This CLI tool automates the entire setup and configuration process, making it as easy as create-next-app.
This monorepo contains 2 npm packages that share the same GitHub repository but are published separately:
The main command-line interface for setting up and managing OpenNext.js projects.
Installation:
npm install -g @jsonbored/opennextjs-cli
# or
pnpm add -g @jsonbored/opennextjs-cliAlias: onjs (shorter command)
Documentation: See packages/opennextjs-cli/README.md for complete CLI documentation.
Model Context Protocol server that enables AI tools to interact with OpenNext.js projects.
Installation:
npm install -g @jsonbored/opennextjs-mcpDocumentation: See packages/opennextjs-mcp/README.md for complete MCP documentation.
Note: The MCP server is automatically configured when you run opennextjs-cli mcp setup.
npm install -g @jsonbored/opennextjs-cli
# or use the alias
onjs --versionopennextjs-cli init my-project
# or
onjs init my-projectcd your-existing-nextjs-project
opennextjs-cli add
# or
onjs addpnpm deploy
# or
npm run deploy- Node.js 18.0.0 or higher
- pnpm 8.0.0 or higher (recommended)
- Git (for version control)
# Clone repository
git clone https://github.com/JSONbored/opennextjs-cli.git
cd opennextjs-cli
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test# Watch mode for CLI package
cd packages/opennextjs-cli
pnpm dev
# Watch mode for MCP package
cd packages/opennextjs-mcp
pnpm dev
# Run CLI locally
cd packages/opennextjs-cli
pnpm dev
# Then use: node dist/index.js <command># Run all tests
pnpm test
# Run CLI tests
cd packages/opennextjs-cli
pnpm test
# Run MCP tests
cd packages/opennextjs-mcp
pnpm test
# Run with coverage
pnpm test:coverage# Lint all packages
pnpm lint
# Lint specific package
cd packages/opennextjs-cli
pnpm lint- Interactive Setup Wizard - Beautiful step-by-step prompts for configuration
- Automatic Configuration - Generates
open-next.config.ts,wrangler.toml, and more - Smart Defaults - Best practices built-in with sensible defaults
- Dependency Management - Automatically installs required packages
- Type-Safe - Full TypeScript support with Zod validation
- Modern TUI - Beautiful terminal UI using
@clack/prompts
- Safety Checks - Comprehensive pre-operation validation
- Automatic Rollback - Reverts changes on failure
- Auto-Backup - Backs up files before modifications
- Monorepo Support - Detects and handles monorepo structures
- Path Validation - Prevents unsafe file operations
- MCP Server - Model Context Protocol server for AI tool integration
- Cursor/Claude Desktop - Seamless integration with AI coding assistants
- Project Insights - AI can query project status, validate configs, and more
The CLI provides 15 commands for complete project management:
init- Create new Next.js project with OpenNext.jsadd- Add OpenNext.js to existing projectconfig- Update configuration
status- Show project statusvalidate- Validate configurationdoctor- Health checks with auto-fixsetup- Configure CLI settings
deploy- Deploy to Cloudflarepreview- Start local preview serverupdate- Update dependencies
env- Manage environment variablescloudflare- Manage Cloudflare authentication
migrate- Migrate from Vercel/Netlifymcp- Setup MCP servercompletion- Shell completion scripts
Full Documentation: See packages/opennextjs-cli/README.md
The MCP server provides AI tools with programmatic access to your OpenNext.js projects:
get_project_status- Get project informationvalidate_configuration- Validate setupcheck_health- Health checkslist_environments- List Cloudflare environmentsdeploy_to_cloudflare- Deploy projectstart_preview_server- Start previewupdate_configuration- Update config
opennextjs://config/wrangler.toml- Wrangler configopennextjs://config/open-next.config.ts- OpenNext configopennextjs://config/package.json- Package configopennextjs://project/structure- Project structure
setup-opennextjs-project- Setup guidetroubleshoot-deployment- Troubleshootingoptimize-cloudflare-config- Optimization tips
Full Documentation: See packages/opennextjs-mcp/README.md
- Node.js 18.0.0 or higher
- pnpm 8.0.0+ (recommended) or npm/yarn/bun
- Cloudflare Account (for deployment)
- Wrangler CLI (installed automatically)
The CLI supports multiple caching strategies:
| Strategy | Description | Use Case |
|---|---|---|
static-assets |
SSG-only, no R2 needed | Simple static sites |
r2 |
R2 Incremental Cache | Most Next.js apps (recommended) |
r2-do-queue |
ISR with time-based revalidation | Dynamic content with ISR |
r2-do-queue-tag-cache |
Full-featured with on-demand revalidation | Complex apps with on-demand ISR |
Completed:
- β Phase 1: Core CLI commands (init, add, config, status, validate)
- β Phase 2: Advanced commands (deploy, preview, update, env, cloudflare, doctor)
- β Phase 5: MCP server (tools, resources, prompts)
Coming Soon:
- Phase 3: Templates, migration helpers, dry-run mode, config export/import
- Phase 4: CI/CD integration, testing setup, monitoring setup
Contributions are welcome! Please see our contributing guidelines (coming soon).
# Clone repository
git clone https://github.com/JSONbored/opennextjs-cli.git
cd opennextjs-cli
# Install dependencies
pnpm install
# Build packages
pnpm build
# Run tests
pnpm test
# Run CLI locally
cd packages/opennextjs-cli
pnpm dev- OpenNext.js - The core adapter that makes this possible
- OpenNext.js Cloudflare - Cloudflare-specific implementation
- Cloudflare Workers - Deployment platform
- Model Context Protocol - MCP specification
This tool is built for and powered by OpenNext.js, an amazing project that makes deploying Next.js to various platforms possible.
- OpenNext.js Cloudflare: https://github.com/opennextjs/opennextjs-cloudflare
- Official Documentation: https://opennext.js.org/cloudflare
- Package:
@opennextjs/cloudflareon npm
Made with π by JSONbored
β Star on GitHub β’ π¦ npm CLI β’ π¦ npm MCP β’ π Report Issue