Pular para o conteúdo

Deploy an existing project

Atualizado em Ver como Markdown

Wrangler can automatically detect your framework and configure your project for Cloudflare Workers. This allows you to deploy existing projects with a single command, without manually setting up configuration files or installing adapters.

How it works

When you run wrangler deploy or wrangler setup in a project directory without a Wrangler configuration file, Wrangler will:

  1. Detect your framework - Analyzes your project to identify the framework you're using
  2. Prompt for confirmation - Shows the detected settings and asks you to confirm before making changes
  3. Install adapters - Installs any required Cloudflare adapters for your framework
  4. Generate configuration - Creates a wrangler.jsonc file with appropriate settings
  5. Update package.json - Adds helpful scripts like deploy, preview, and cf-typegen
  6. Configure git - Adds Wrangler-specific entries to .gitignore

Supported frameworks

Automatic configuration supports the following frameworks:

Framework Adapter/Tool Notes
Next.js @opennextjs/cloudflare Runs @opennextjs/cloudflare migrate automatically. R2 caching is configured if available.
Astro @astrojs/cloudflare Runs astro add cloudflare automatically
SvelteKit @sveltejs/adapter-cloudflare Runs sv add sveltekit-adapter automatically
Nuxt Built-in Cloudflare preset
React Router Cloudflare Vite plugin
Solid Start Built-in Cloudflare preset
TanStack Start Cloudflare Vite plugin
Angular
Analog Built-in Cloudflare preset
Vite Cloudflare Vite plugin
Vike
Waku
Static sites None Any directory with an index.html

Automatic configuration may also work with other projects, such as React or Vue SPAs. Try running wrangler deploy or wrangler setup to see if your project is detected.

Files created and modified

When automatic configuration runs, the following files may be created or modified:

wrangler.jsonc

A new Wrangler configuration file is created with settings appropriate for your framework:

{
	"$schema": "node_modules/wrangler/config-schema.json",
	"name": "my-project",
	"main": "dist/_worker.js/index.js",
	// Set this to today's date
	"compatibility_date": "2026-07-20",
	"compatibility_flags": ["nodejs_compat"],
	"assets": {
		"binding": "ASSETS",
		"directory": "dist",
	},
	"observability": {
		"enabled": true,
	},
}
"$schema" = "node_modules/wrangler/config-schema.json"
name = "my-project"
main = "dist/_worker.js/index.js"
# Set this to today's date
compatibility_date = "2026-07-20"
compatibility_flags = [ "nodejs_compat" ]

[assets]
binding = "ASSETS"
directory = "dist"

[observability]
enabled = true

The exact configuration varies based on your framework.

package.json

New scripts are added to your package.json:

{
	"scripts": {
		"deploy": "npm run build && wrangler deploy",
		"preview": "npm run build && wrangler dev",
		"cf-typegen": "wrangler types"
	}
}

.gitignore

Wrangler-specific entries are added:

# wrangler files
.wrangler
.dev.vars*
!.dev.vars.example

.assetsignore

For frameworks that generate worker files in the output directory, an .assetsignore file is created to exclude them from static asset uploads:

_worker.js
_routes.json

Using automatic configuration

Deploy with automatic configuration

To deploy an existing project, run wrangler deploy in your project directory:


								
									
									npx
									 wrangler deploy
								
							

Wrangler will detect your framework, show the configuration it will apply, and prompt you to confirm before making changes and deploying.

Configure without deploying

To configure your project without deploying, use wrangler setup:


								
									
									npx
									 wrangler setup
								
							

This is useful when you want to review the generated configuration before deploying.

Preview changes with dry run

To see what changes would be made without actually modifying any files:


								
									
									npx
									 wrangler setup --dry-run
								
							

This outputs a summary of the configuration that would be generated.

Non-interactive mode

To skip the confirmation prompts, use the --yes flag:


								
									
									npx
									 wrangler deploy --yes
								
							

This applies the configuration automatically using sensible defaults. This is useful in CI/CD environments or when you want to accept the detected settings without reviewing them.

Importing a repository from the dashboard

When you import a GitHub or GitLab repository via the Cloudflare dashboard, autoconfig runs non-interactively. If your repository does not have a Wrangler configuration file, Workers Builds will create a pull request with the necessary configuration.

The PR includes all the configuration changes described above. A preview deployment is generated so you can test the changes before merging. Once merged, your project is ready for deployment.

For more details, refer to Automatic pull requests.

Skipping automatic configuration

If you do not want automatic configuration to run, ensure you have a valid Wrangler configuration file (wrangler.toml, wrangler.json, or wrangler.jsonc) in your project before running wrangler deploy.

You can also manually configure your project by following the framework-specific guides in the Framework guides.

Next.js caching

For Next.js projects, automatic configuration will set up R2 for caching if your Cloudflare account has R2 enabled. R2 caching improves performance for Incremental Static Regeneration (ISR) and other Next.js caching features.

  • If R2 is enabled on your account: Automatic configuration creates an R2 bucket and configures caching automatically.
  • If R2 is not enabled: Your project will be configured without caching. You can enable R2 later and manually configure caching by following the OpenNext caching documentation.

To check if R2 is enabled or to enable it, go to Storage & Databases > R2 in the Cloudflare dashboard.

Troubleshooting

Multiple frameworks detected

When you import a repository via Workers Builds in the Cloudflare dashboard, automatic configuration will fail if your project contains multiple frameworks. To resolve this, set the root directory to the path containing only one framework. For monorepos, refer to monorepo setup.

When running wrangler deploy or wrangler setup locally, Wrangler will prompt you to select which framework to use if multiple frameworks are detected.

Framework not detected

If your framework is not detected, ensure your package.json includes the framework as a dependency.

Configuration already exists

If a Wrangler configuration file already exists, automatic configuration will not run. To reconfigure your project, delete the existing configuration file and run wrangler deploy or wrangler setup again.

Workspaces

Support for monorepos and npm/yarn/pnpm workspaces is currently limited. Wrangler analyzes the project directory where you run the command, but does not detect dependencies installed at the workspace root. This can cause framework detection to fail if the framework is listed as a dependency in the workspace's root package.json rather than in the individual project's package.json.

If you encounter issues, report them in the Wrangler GitHub repository.