Cloudflare Integration
Flareforge is fundamentally an opinionated framework designed exclusively for the Cloudflare ecosystem.
Cloudflare is not only a deployment target, it is the core of the architecture, enabling developers to build highly scalable, performant, and cost-efficient applications.
Why Cloudflare?
Section titled “Why Cloudflare?”The decision to build Flareforge on Cloudflare is based on a set of core principles that benefit developers.
- Cloudflare provides a complete, serverless toolkit for building full-stack applications without managing traditional server infrastructure. Flareforge integrates these services into a cohesive whole:
- Cloudflare Workers for serverless compute at the edge.
- D1 for serverless SQL databases.
- R2 for S3-compatible object storage.
- Queues for reliable background job processing.
- By deploying applications on Cloudflare’s global edge network, applications are inherently fast for users worldwide. The serverless architecture scales automatically to handle traffic spikes without manual intervention.
- The framework is designed to leverage Cloudflare’s consumption-based pricing and generous free tiers, making it possible to launch and operate a scalable application at a very low cost.
Automated Provisioning
Section titled “Automated Provisioning”Flareforge abstracts away the manual process of configuring Cloudflare resources. The flareforge setup
command handles the entire infrastructure provisioning process directly from the CLI.
When you run the command, it performs the following actions:
- It checks your Cloudflare login status using
wrangler whoami
and prompts for authentication if you are not logged in. - It programmatically runs
wrangler
commands to create all necessary cloud resources for your project. This includes creating a D1 database, an R2 bucket, and a message Queue. - It automatically updates your
wrangler.jsonc
file with the correct IDs and bindings for the newly created resources. This connects your Worker code to your database, storage, and queue without manual configuration. - It generate TypeScript definitions for all your bindings, ensuring full type safety when interacting with Cloudflare services in your code.
Standard Wrangler Compatibility
Section titled “Standard Wrangler Compatibility”While Flareforge provides a managed setup and development experience, the generated project is a standard Cloudflare Workers project.
This means you are not locked into using the Flareforge CLI for every action. You can use the standard wrangler
CLI for all typical operations, such as:
- Deploying your application:
wrangler deploy
- Managing secrets:
wrangler secret put <KEY>
- Interacting with D1 directly:
wrangler d1 execute <DATABASE_NAME> --command="SELECT * FROM users"
The flareforge dev
command is recommended for local development because it integrates the code generation step, but the underlying project remains fully compatible with the standard Cloudflare toolkit.