Configuration
When connecting your Git repository to your Worker, you can customize the configurations needed to build and deploy your Worker.
Build settings can be found by navigating to Settings > Build within your Worker.
Note that when you update and save build settings, the updated settings will be applied to your next build. When you retry a build, the build configurations that exist when the build is retried will be applied.
Setting | Description |
---|---|
Git account | Select the Git account you would like to use. After the initial connection, you can continue to use this Git account for future projects. |
Git repository | Choose the Git repository you would like to connect your Worker to. |
Git branch | Select the branch you would like Cloudflare to listen to for new commits. This will be defaulted to main . |
Build command (Optional) | Set a build command if your project requires a build step (e.g. npm run build ). This is necessary, for example, when using a front-end framework such as Next.js or Remix. |
Deploy command | The deploy command lets you set the specific Wrangler command used to deploy your Worker. Your deploy command will default to npx wrangler deploy but you may customize this command. Workers Builds will use the Wrangler version set in your package json . |
Root directory (Optional) | Specify the path to your project. The root directory defines where the build command will be run and can be helpful in monorepos to isolate a specific project within the repository for builds. |
API token (Optional) | The API token is used to authenticate your build request and authorize the upload and deployment of your Worker to Cloudflare. By default, Cloudflare will automatically generate an API token for your account when using Workers Builds, and continue to use this API token for all subsequent builds. Alternatively, you can create your own API token, or select one that you already own. |
Build variables and secrets (Optional) | Add environment variables and secrets accessible only to your build. Build variables will not be accessible at runtime. If you would like to configure runtime variables you can do so in Settings > Variables & Secrets |
You can run your deploy command using the package manager of your choice.
If you have added a Wrangler deploy command as a script in your package.json
, then you can run it by setting it as your deploy command. For example, npm run deploy
.
Examples of other deploy commands you can set include:
Example Command | Description |
---|---|
npx wrangler versions upload | Upload a version of your Worker without deploying it as the Active Deployment. |
npx wrangler deploy --assets ./public/ | Deploy your Worker along with static assets from the specified directory. Alternatively, you can use the assets binding. |
npx wrangler deploy --env staging | If you have a Wrangler environment Worker, you should set your deploy command with the environment flag. For more details, see Advanced Setups. |
When you select Create new token, a new API token will be created automatically with the following permissions:
- Account: Account Settings (read), Workers Scripts (edit), Workers KV Storage (edit), Workers R2 Storage (edit)
- Zone: Workers Routes (edit) for all zones on the account
- User: User Details (read), Memberships (read)
You can configure the permissions of this API token by navigating to My Profile > API Tokens for user tokens.
It is recommended to consistently use the same API token across all uploads and deployments of your Worker to maintain consistent access permissions.
Static assets and frameworks are now supported in Cloudflare Workers. Learn to set up Workers projects and the commands for each framework in the framework guides: