Project template for scaffolding Cloudflare Workers projects.
- Supports multiple worker scripts within the same project
- Source code bundling with Babel and Rollup
- Pre-configured with TypeScript, ESLint, Jest, and Prettier
- Pre-commit Git hook(s) using Husky; CI/CD workflow (GitHub Actions)
- Code snippets and other VSCode settings
This project was bootstrapped with Cloudflare Starter Kit. Be sure to join our Discord channel for assistance.
├──
.github
— GitHub configuration including CI/CD workflows
├──
.vscode
— VSCode settings including code snippets, recommended extensions etc.
├──
core
— core modules and utility functions
├──
scripts
— Automation scripts, such as yarn deploy
├──
workers
— Cloudflare Worker scripts
├──
bindings.d.ts
— KV bindings etc.
├──
package.json
— npm dependencies and Yarn scripts
├──
rollup.config.js
— code bundling configuration for Rollup
└──
tsconfig.json
— TypeScript configuration
Cloudflare Workers, TypeScript, Babel, ESLint, Prettier, Jest, Yarn v2 with PnP, Rollup.
- Node.js v14 or newer, Yarn package manager
- VS Code editor with recommended extensions
- Clone the repo
git clone -o seed https://github.com/kriasoft/cloudflare-starter-kit.git
- Install project dependencies —
yarn install
- Optionally, configure Husky —
yarn setup
- Add or edit Cloudflare Workers inside of the
workers
folder - Build and deploy them by running
yarn build
,yarn deploy
.
IMPORTANT: Ensure that VSCode is using the workspace versions of TypeScript and ESLint.
yarn build
— Compiles and bundles Cloudflare Workers into the.build
folderyarn lint
— Validate code using ESLintyarn tsc
— Validate code using TypeScript compileryarn test
— Run unit tests with Jest, Supertestyarn deploy
— Deploys the app to Cloudflare
Ensure that Cloudflare account credentials are present in the .env
file:
# Cloudflare
# https://dash.cloudflare.com/
# https://developers.cloudflare.com/api/tokens/create
CLOUDFLARE_ACCOUNT_ID=
CLOUDFLARE_ZONE_ID=
CLOUDFLARE_API_TOKEN=
Compile and deploy the app by running:
$ yarn build
$ yarn deploy [--env #0]
Where --env
argument is the target environment, e.g. yarn deploy --env=prod
.
yarn set version latest
— Bump Yarn to the latest versionyarn upgrade-interactive
— Update Node.js modules (dependencies)yarn pnpify --sdk vscode
— Update TypeScript, ESLint, and Prettier settings in VSCode
- React Starter Kit — front-end template for React, Relay stack
- Node.js API Starter Kit — project template, pre-configured with Node.js, GraphQL, and PostgreSQL
- GraphQL API and Relay Starter Kit — monorepo template, pre-configured with GraphQL API, React, and Relay
Anyone and everyone is welcome to contribute. Start by checking out the list of open issues marked help wanted. However, if you decide to get involved, please take a moment to review the guidelines.
Copyright © 2020-present Kriasoft. This source code is licensed under the MIT license found in the LICENSE file.
Made with ♥ by Konstantin Tarkus (@koistya, blog) and contributors.