Cloudflare D1

See all terms starting with C

Cloudflare D1 is a serverless database that is native to the Cloudfare Workers platform. It is build on SQLite and is designed to be a fast, scalable, and less expensive alternative to products such as Azure SQL, AWS Aurora, CockroachDB, and PlanetScale.

Cloudflare D1 pricing is based on the pay-as-you-go model, and a genererous free tier is available through the Cloudflare Workers free plan. In the free tier, you are allowed to read 5,000,000 rows per day, write 100,000 rows per day, and store up to 5GB of data.

More resources are available if you already pay for the Workers Paid plan. If thats the case your plan includes 25 billion rows reads per month, 50 million rows write per month, and a charge of $0.75 per GB of data stored that goes over the free tier limit. As you can see, the Cloudflare D1 billing is based on usage, the queries you issue against a D1 database, and storage, how much data you store in the database. Cloudflare also offers a Scale-to-Zero feature, which means that you don’t pay for the database when it’s not being used.

You can get started with D1 by both importing an existing SQLite database or creating a new one from scratch. The database is accessible from the Cloudflare Dashboard, and you can create, read, update, and delete data from the console. You can also use the D1 API to interact with the database from your Workers, and the Wrangler CLI to manage your database from the command line. An alternative to the D1 API is to use the Drizzle ORM, which has added support for D1 and allows you to interact with the database using the same tools you would use with a traditional database like PostgreSQL or MySQL.

Cloudflare D1 makes possible to build full application backends using Cloudflare Workers. Before D1, using third-party databases was not directly possible because of the constraints of opening TCP connections from the edge. You needed to use services like Prisma Accelerate that would act as a proxy between your Workers and the database by providing cache and connections pooling.

Now this has changed and you can use D1 to store and query your data directly from your Cloudflare Workers.

Want to supercharge your website with serverless functions designed for optimizing SEO, performance, security, marketing, and more? Try Flaremingo:

Create a free account!

Want to supercharge your website with serverless functions designed for optimizing SEO, performance, security, marketing, and more? Try Flaremingo:

Create a free account!