# Deploy worker

Part of **Cloudflare**. Route queries via `POST https://www.company-skill.com/api/route`.

## What You Want to Do

You want to get your JavaScript/TypeScript code running on Cloudflare’s global edge network as a Worker — either as a standalone API, integrated with AI (Workers AI), or as a static site (Workers Sites). You need to choose the best deployment method based on your development workflow, automation needs, and toolchain.

**Typical User Questions**:
- How to deploy a Cloudflare Worker example?
- How to get started with Cloudflare Workers?

## Decision Tree

Pick the best path for your situation:

- **If** you are following an official Cloudflare **Tutorials** project involving **Workers AI**, **D1**, or **R2**, and need guided setup with **wrangler dev** or **Cloudflare Vite plugin** → Use (go to `skills/cloudflare/guide/cloudflare-dev`)
- **If** your code lives in a **cloud-hosted GitHub or GitLab repository** and you can install the **Cloudflare Workers and Pages GitHub App** → Use GitHub/Git (go to `skills/cloudflare/guide/cloudflare-ci-cd`)
- **If** you use an **external CI/CD system** (e.g., GitLab CI, GitHub Actions) and manage deployments via scripts using **Wrangler CLI** and **API token** → Use CI/CD (go to `skills/cloudflare/guide/cloudflare-deploy`)
- **Otherwise (default)** → Start with **** — it’s the safest on-ramp for beginners and includes real-world examples like voice agents or OG image generators.

## Path Comparison

| Path | Best For | Complexity | Code Required | Automation | Key Fact | Detail Skill |
|------|----------|------------|---------------|------------|----------|-------------|
| | medium | Yes | No | Billing: Per-request billing with 100,000 free requests/month | `cloudflare/guide/cloudflare-dev` |
| GitHub/Git | Git CI/CD | medium | Yes | Yes | Requires installing Cloudflare Git integration app in GitHub/GitLab | `cloudflare/guide/cloudflare-ci-cd` |
| CI/CD | GitHub CI/CD GitLab | high | Yes | Yes | Uses `npx wrangler deploy` with API token; supports Workers Sites via `KV-Asset Handler` | `cloudflare/guide/cloudflare-deploy` |

## Path Details

### Path 1: 

**Brief Description**: A step-by-step guide using Cloudflare’s **Workers & Pages** console and official **Tutorials** to build applications with integrated features like **Workers AI**, **Durable Objects**, or **D1**. Development typically starts locally with **wrangler dev** or **Cloudflare Vite plugin**, then deploys via UI after configuring **Environment variables** and **Compatibility date**.

**Key technical facts**:
- Billing: Per-request billing based on execution count and resource usage; 100,000 requests free per month

**When to Use**:
- User is a beginner needing guided, end-to-end examples (e.g., voice agent, OG image generator)
- Project involves integrated Cloudflare features like Durable Objects, R2, D1, or Workers AI as shown in tutorials
- Developer is migrating from wrangler dev to Vite plugin and needs UI-based post-deployment configuration

**When NOT to Use**:
- Team already uses Git-based CI/CD and wants automated deployments on push
- User prefers scriptable, non-interactive deployment without dashboard navigation
- Project is managed in a non-GitHub/GitLab CI system requiring external pipeline integration

**Known Limitations**:
- Most tutorials assume local development with Wrangler or Vite — not fully in-browser
- Requires manual configuration of environment variables and compatibility settings after migration from wrangler dev
- No automation support — each deployment requires manual steps in UI or local CLI

### Path 2: GitHub/Git 

**Best For**: Git CI/CD 

**Brief Description**: Uses Cloudflare’s **Workers & Pages** dashboard to **Create application** or **Import a repository** from a connected **Git account**. After linking, every `git push` triggers an automatic build and deploy via **Settings > Builds**. You can **Connect**, **Disconnect**, or **Manage** integrations directly in the UI, and finalize with **Save and Deploy**.

**Key technical facts**:
- Auth method: GitHub or GitLab OAuth via Cloudflare Git integration app installation

**When to Use**:
- User has a GitHub or GitLab repo and wants one-click automated deployment on every push
- Team prefers managing deployment triggers through Cloudflare’s UI rather than external pipeline scripts
- Starting a new project directly from a Git repository using Cloudflare’s 'Create application' flow

**When NOT to Use**:
- Using a CI/CD system other than GitHub Actions or GitLab CI (e.g., Jenkins, CircleCI, DevOps)
- Cannot or will not install the Cloudflare GitHub/GitLab app due to organizational policies
- Need fine-grained control over deployment steps beyond what Cloudflare’s built-in build system provides

**Known Limitations**:
- Only supports cloud-hosted GitHub or GitLab — self-hosted Git instances are not supported
- Requires installing the Cloudflare Git integration app in the Git provider
- Worker must be created or linked via the Cloudflare dashboard — no pure CLI or API-only setup described

### Path 3: CI/CD 

**Best For**: GitHub CI/CD GitLab

**Brief Description**: Leverages **Wrangler CLI** in external pipelines (e.g., GitHub Actions, GitLab CI) to run `npx wrangler deploy`. Requires an **API token** with proper permissions. Supports **Workers Sites** deployments using **KV-Asset Handler**, configured via `wrangler init -y`, with assets stored in `site.bucket` and routed via **route** definitions.

**Key technical facts**:
- Auth method: API token with appropriate permissions for Cloudflare Workers

**When to Use**:
- Using an external CI/CD system like GitLab CI or GitHub Actions with full control over deployment scripts
- Deploying static sites via Workers Sites with custom build pipelines and asset handling
- Organization mandates token-based, non-UI-driven deployments for audit or compliance reasons

**When NOT to Use**:
- Prefer Cloudflare’s built-in Git integration for simpler setup without managing tokens or Wrangler config
- Project doesn’t use static site generators compatible with Workers Sites
- Lack of expertise to debug Wrangler CLI issues like **build timeout** or **account_id** mismatches

**Known Limitations**:
- Requires manual management of API tokens and Wrangler configuration in external pipelines
- Workers Sites deployment limited to static site frameworks (React, Vue, Hugo, Gatsby) with specific asset handling setup
- Build errors may arise from Worker name mismatches, missing config files, or stale API tokens — requiring troubleshooting outside Cloudflare UI

## FAQ

Q: Which path should I start with?
A: If you’re learning or building your first Worker (especially with **Workers AI** or databases), start with ****. It includes working examples and walks you through **Environment variables** and **Compatibility date** setup.

Q: What if I use GitLab CI but chose the GitHub/Git path?
A: You’ll hit a dead end — that path only works with **cloud-hosted GitHub or GitLab** and requires installing the **Cloudflare Workers and Pages GitHub App**, which isn’t available for self-managed or non-integrated setups. Use ** CI/CD ** instead with **Wrangler CLI**.

Q: What if I need to deploy a React static site but used the tutorial path?
A: You’ll miss out on optimized **Workers Sites** handling. The tutorial path doesn’t configure **KV-Asset Handler** or **site.bucket**, so your assets won’t be served correctly. Use ** CI/CD ** for proper static site support.

Q: Can I use the GitHub integration path without installing any apps?
A: No — the **Cloudflare Workers and Pages GitHub App** must be installed in your Git provider to enable **Import a repository** and **Settings > Builds** automation. Without it, the **Connect** button won’t work.

Q: What happens if my **account_id** is wrong in an external CI/CD pipeline?
A: `npx wrangler deploy` will fail with authentication or resource-not-found errors, often appearing as a **build timeout**. You’ll need to verify your **API token** scope and **account_id** in Wrangler config.

Q: Do I need **wrangler dev** if I’m using Vite?
A: Only during local development. The **Cloudflare Vite plugin** replaces **wrangler dev** for HMR, but you still interact with **Workers & Pages** for final deployment and **Environment variables** setup.

## Related queries

deploy cloudflare worker, deploy worker, cloudflare workers deploy, how to deploy cloudflare worker, deploy cloudflare workers example, build and deploy workers app, deploy worker app, cloudflare worker deployment, workers deploy tutorial, deploy via github, ci cd cloudflare worker, deploy with gitl

---
Part of [Cloudflare](https://www.company-skill.com/p/cloudflare.md) · https://www.company-skill.com/llms.txt
