MCPcopy Index your code
hub / github.com/cloudflare/templates

github.com/cloudflare/templates @v9.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v9.0.0 ↗ · + Follow
22,443 symbols 24,750 edges 368 files 3,776 documented · 17%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Templates for Cloudflare Workers

Cloudflare Workers let you deploy serverless code instantly across the globe for exceptional performance, reliability, and scale. This repository contains a collection of starter templates for building full-stack applications on Workers. You are encouraged to use, modify, and extend this code!

Getting Started

There are two ways to start building with a template in this repository: the Cloudflare dashboard and C3 (the create-cloudflare CLI).

Starting from the Dashboard

After logging in or signing up through the Cloudflare dashboard, open the Workers templates page and select a template to get started with. From here, you can create a repository and deploy your first Worker without needing a local development environment.

Starting via CLI

To get started locally, run one of the following commands:

npm create cloudflare@latest
# or
pnpm create cloudflare@latest
# or
yarn create cloudflare@latest

For more information on getting started with our CLI, check out the getting started guide.

Additional Resources

Questions about Workers? Join the official Cloudflare Discord or check out the Workers docs!

End-to-End Testing

This repository includes a comprehensive Playwright-based E2E test suite that validates all templates to ensure they work correctly. The test system supports both local development mode (spinning up dev servers) and live mode (testing against deployed templates).

Running E2E Tests

Local Development Mode (Default)

By default, tests run against locally started development servers:

# Run all E2E tests
pnpm run test:e2e

# Run tests for specific templates
pnpm run test:e2e astro-blog-starter-template.spec.ts
pnpm run test:e2e saas-admin-template.spec.ts

# Run tests with UI mode for debugging
pnpm run test:e2e --ui

In local mode:

  • Tests start development servers automatically for each template
  • Uses one worker to prevent port conflicts
  • Servers are properly cleaned up between different template tests
  • Longer timeouts to account for build and startup time

Live Mode (Testing Deployed Templates)

To test against live deployed templates, set the PLAYWRIGHT_USE_LIVE environment variable:

# Run tests against live deployed templates
pnpm run test:e2e:live

# Run specific template tests in live mode
pnpm run test:e2e:live saas-admin-template.spec.ts

In live mode:

  • Tests run against https://{template-name}.templates.workers.dev
  • Enables parallel execution (up to 4 workers locally, 2 in CI)
  • Faster execution since no local server startup required
  • Shorter timeouts since templates are already running

Test Architecture

The test system includes:

  • Automatic template discovery: Finds all *-template directories and analyzes their framework
  • Smart server management: Detects framework type (Astro, Next.js, Vite, etc.) and uses appropriate ports
  • Reliable cleanup: Properly terminates process trees between test runs
  • Flexible URL resolution: Automatically determines live URLs from wrangler.json configuration

Writing Template Tests

Template tests should be named {template-name}.spec.ts and placed in the playwright-tests/ directory:

import { test, expect } from "./fixtures";

test.describe("My Template", () => {
    test("should render correctly", async ({ page, templateUrl }) => {
        await page.goto(templateUrl);
        await expect(page.getByRole("heading", { name: "Welcome" })).toBeVisible();
    });
});

The templateUrl fixture automatically provides the correct URL (local dev server or live deployment) based on the test mode.

Playwright Codegen

Playwright includes a test code generation utility that records your actions in a chromium browswer. To start the codegen utility run

pnpm playwright codgen

Contributing

We welcome template contributions! If there's a Workers template you think would be valuable, please read our contributing guide and open an issue or pull request.

Extension points exported contracts — how you extend this code

AiTextGeneration (Interface)
* Minimal interface for Workers AI text generation. * Uses a loose return type to stay compatible with the Cloudflare ` [2 …
commerce-llms-txt-template/src/enrichment/index.ts
ServiceWorkerGlobalScope (Interface)
* The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a se
commerce-llms-txt-template/worker-configuration.d.ts
ServiceWorkerGlobalScope (Interface)
* The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a se
durable-chat-template/src/server/worker-configuration.d.ts
ServiceWorkerGlobalScope (Interface)
* The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a se
multiplayer-globe-template/src/server/worker-configuration.d.ts
ServiceWorkerGlobalScope (Interface)
* The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a se
chanfana-openapi-template/worker-configuration.d.ts
ServiceWorkerGlobalScope (Interface)
* The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a se
openauth-template/worker-configuration.d.ts
ServiceWorkerGlobalScope (Interface)
* The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a se
astro-blog-starter-template/worker-configuration.d.ts
ServiceWorkerGlobalScope (Interface)
* The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a se
next-starter-template/env.d.ts

Core symbols most depended-on inside this repo

json
called by 250
workers-builds-notifications-template/worker-configuration.d.ts
get
called by 160
workers-builds-notifications-template/worker-configuration.d.ts
log
called by 121
workers-builds-notifications-template/worker-configuration.d.ts
replace
called by 121
workers-builds-notifications-template/worker-configuration.d.ts
error
called by 116
workers-builds-notifications-template/worker-configuration.d.ts
log
called by 81
workers-for-platforms-template/scripts/setup.js
fetch
called by 74
workers-builds-notifications-template/worker-configuration.d.ts
text
called by 67
workers-builds-notifications-template/worker-configuration.d.ts

Shape

Interface 11,986
Method 7,469
Class 2,458
Function 530

Languages

TypeScript100%
Go1%

Modules by API surface

x402-proxy-template/worker-configuration.d.ts769 symbols
saas-admin-template/worker-configuration.d.ts769 symbols
react-router-starter-template/worker-configuration.d.ts769 symbols
nlweb-template/worker-configuration.d.ts769 symbols
next-starter-template/env.d.ts769 symbols
commerce-llms-txt-template/worker-configuration.d.ts769 symbols
workflows-starter-template/worker-configuration.d.ts768 symbols
workers-builds-notifications-template/worker-configuration.d.ts768 symbols
vite-react-template/worker-configuration.d.ts768 symbols
text-to-image-template/worker-configuration.d.ts768 symbols
react-router-postgres-ssr-template/worker-configuration.d.ts768 symbols
react-router-hono-fullstack-template/worker-configuration.d.ts768 symbols

Datastores touched

dbnameDatabase · 1 repos
mydatabaseDatabase · 1 repos
(mysql)Database · 1 repos

For agents

$ claude mcp add templates \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact