跳到正文

Cloudflare Templates

热门趋势活跃
cloudflare/templates

用于在 Cloudflare Workers 上构建全栈应用的起步模板合集。即时将无服务器代码部署到全球,性能、可靠性和扩展性俱佳。

在 GitHub 查看
星标
2146
Fork
1048
关注
2146
未关闭 Issue
202

该介绍目前仅提供英文版本。

🌐 Project Overview

Cloudflare Templates is the official collection of starter templates for building modern, full-stack applications on Cloudflare Workers. This repository provides everything you need to deploy serverless code instantly across Cloudflare’s global edge network, offering exceptional performance, reliability, and scale for web applications of all sizes.

⭐ Core Features

  • 🚀 Instant Global Deployment

    • Deploy across 200+ cities worldwide
    • Zero cold starts with edge computing
    • Automatic scaling and load balancing
    • Sub-50ms response times globally
  • 🛠️ Complete Template Collection

    • 20+ production-ready starter templates
    • Full-stack application examples
    • Database integration templates
    • Modern framework support
  • ⚡ Modern Web Technologies

    • TypeScript-first development (52.9%)
    • React, Next.js, Astro, Remix support
    • Database templates (D1, Postgres, MySQL)
    • Authentication and session management
  • 🎯 Developer Experience

    • One-command deployment via CLI
    • Dashboard-based quick start
    • Hot reload development
    • Built-in debugging tools

🛠️ Technology Stack

Languages & Frameworks

  • TypeScript (52.9%) - Type-safe development
  • JavaScript (23.0%) - Client-side scripting
  • CSS (9.1%) - Modern styling
  • HTML (7.6%) - Semantic markup
  • Astro (7.0%) - Static site generation
  • MDX (0.4%) - Documentation
  • React Applications - Modern React with Workers
  • Next.js Starter - Full-stack Next.js deployment
  • Astro Blog - Static blog with dynamic features
  • Remix Applications - Server-side React framework
  • Hono API - Fast and lightweight web framework
  • Database Templates - D1, Postgres, MySQL integration

🚀 Quick Start

Dashboard Deployment

  1. Log into Cloudflare Dashboard

    • Visit Workers Templates
    • Select your preferred template
    • Click “Deploy” for instant deployment
  2. Connect GitHub Repository

    • Link your GitHub account
    • Create repository from template
    • Automatic CI/CD setup

CLI Development

# Install create-cloudflare CLI
npm create cloudflare@latest

# Or using other package managers
pnpm create cloudflare@latest
yarn create cloudflare@latest

# Follow interactive prompts
# Select template, configure options, deploy

Manual Setup

# Clone specific template
git clone https://github.com/cloudflare/templates
cd templates/[template-name]

# Install dependencies
npm install

# Start development server
npm run dev

# Deploy to Cloudflare
npm run deploy

📂 Template Categories

Frontend Frameworks

  • next-starter-template - Next.js with App Router
  • react-router-starter-template - React Router v6
  • vite-react-template - Vite + React
  • astro-blog-starter-template - Astro static blog
  • remix-starter-template - Remix full-stack

Full-Stack Applications

  • react-postgres-fullstack-template - React + PostgreSQL
  • react-router-hono-fullstack-template - React Router + Hono
  • react-router-postgres-ssr-template - SSR with PostgreSQL
  • saas-admin-template - Complete SaaS admin panel

Database Integration

  • d1-template - Cloudflare D1 SQLite database
  • d1-starter-sessions-api-template - D1 with session management
  • postgres-hyperdrive-template - PostgreSQL with Hyperdrive
  • mysql-hyperdrive-template - MySQL with Hyperdrive

Specialized Applications

  • durable-chat-template - Real-time chat with Durable Objects
  • r2-explorer-template - R2 object storage explorer
  • llm-chat-app-template - AI chat application
  • text-to-image-template - AI image generation
  • multiplayer-globe-template - Interactive multiplayer app

Authentication & Security

  • openauth-template - OAuth authentication
  • to-do-list-kv-template - Todo app with KV storage

🌟 Key Advantages

Performance Benefits

  • Edge Computing - Code runs closer to users
  • Zero Cold Starts - Instant response times
  • Automatic Caching - Built-in performance optimization
  • Global Load Balancing - Traffic distributed intelligently

Developer Productivity

  • No Infrastructure Management - Focus on code, not servers
  • Instant Deployment - From code to production in seconds
  • Built-in Observability - Monitoring and analytics included
  • Cost-Effective - Pay only for what you use

Modern Architecture

  • JAMstack Ready - Static sites with dynamic capabilities
  • API-First Design - Clean separation of concerns
  • Database Integration - Seamless data layer integration
  • Real-time Features - WebSocket and Durable Objects support

📊 Project Statistics

  • ⭐ 1.4k+ GitHub Stars
  • 🍴 758 Forks
  • 🐛 15 Open Issues
  • 👁️ 51 Watchers
  • 📦 MIT License
  • 🏷️ 7 Releases

🎯 Use Cases

Web Applications

  • Modern single-page applications (SPAs)
  • Server-side rendered (SSR) applications
  • Progressive web apps (PWAs)
  • E-commerce platforms

API Development

  • RESTful APIs and microservices
  • GraphQL endpoints
  • Webhook handlers
  • Third-party integrations

Content Management

  • Static blogs and documentation sites
  • Headless CMS frontends
  • Marketing websites
  • Portfolio sites

Real-time Applications

  • Chat applications and messaging
  • Collaborative tools
  • Live data dashboards
  • Multiplayer games

🔧 Advanced Features

Database Options

  • D1 - Cloudflare’s SQLite database
  • Hyperdrive - Connection pooling for external databases
  • KV - Key-value storage for simple data
  • R2 - Object storage for files and media

Authentication Methods

  • OAuth Integration - Google, GitHub, Discord
  • Session Management - Secure user sessions
  • API Key Authentication - Service-to-service auth
  • Custom Auth Flows - Build your own system

Performance Features

  • Caching Strategies - Edge and browser caching
  • Image Optimization - Automatic image processing
  • Minification - Automatic code optimization
  • Compression - Gzip and Brotli support

🌐 Deployment Options

Cloudflare Dashboard

  • Visual deployment interface
  • One-click template deployment
  • Environment variable management
  • Domain and SSL configuration

Wrangler CLI

# Install Wrangler
npm install -g wrangler

# Login to Cloudflare
wrangler login

# Deploy application
wrangler deploy

GitHub Integration

  • Automatic deployments from GitHub
  • Preview deployments for pull requests
  • Environment-specific configurations
  • Rollback capabilities

🤝 Contributing

Template Contributions

  • Submit new template ideas
  • Improve existing templates
  • Add framework integrations
  • Enhance documentation

Community Guidelines

  • Follow TypeScript best practices
  • Include comprehensive documentation
  • Provide working examples
  • Maintain compatibility

📚 Learning Resources

Official Documentation

Community Resources

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Ready to build the next generation of web applications? Start with Cloudflare Templates and deploy your ideas to the edge in minutes!

按共同分类和标签排序的同类开源项目。

全部 Web 框架项目 →