该介绍目前仅提供英文版本。
Workers SDK
Workers SDK (formerly Wrangler) is the official command-line tool for Cloudflare Workers, enabling developers to build, test, and deploy serverless applications on Cloudflare’s global network.
Core Features
- Project Management: Create, develop, and deploy Workers projects
- Local Development: Test Workers locally with miniflare integration
- Pages Integration: Deploy static sites and full-stack applications
- D1 Database: Manage D1 databases directly from the CLI
- R2 Storage: Handle R2 storage buckets and objects
- KV Support: Interact with Workers KV namespaces
- Durable Objects: Deploy and manage Durable Objects
- Custom Builds: Support for custom build processes and configurations
- TypeScript Support: First-class TypeScript development experience
Quick Start
-
Installation:
npm install -g wrangler -
Authentication:
wrangler login -
Create a Project:
wrangler init my-worker cd my-worker -
Development:
wrangler dev -
Deployment:
wrangler deploy
Key Components
- Wrangler CLI: Command-line interface for Workers
- Miniflare: Local development environment
- Dev Tools: Built-in debugging and testing tools
- Configuration: Flexible project configuration
- Templates: Project templates for quick starts
- Plugin System: Extensible plugin architecture
Use Cases
- Building serverless applications
- Deploying static websites
- Creating API endpoints
- Managing Workers KV data
- Handling R2 storage operations
- Developing full-stack applications
- Testing Workers locally
- Managing deployment environments
Advanced Features
- Environment Variables: Secure configuration management
- Custom Domains: Domain management and SSL
- Secret Management: Secure secrets handling
- Multi-environment Support: Dev, staging, and production environments
- Tailored Builds: Custom build configurations
- Asset Management: Static asset handling
- Monitoring: Built-in logging and debugging
Community and Support
License
This project is licensed under the Apache License 2.0.