Connect to databases
Cloudflare Workers can connect to and query your data in both SQL and NoSQL databases, including:
- Traditional hosted relational databases, including Postgres and MySQL.
- Serverless databases: Supabase, MongoDB Atlas, PlanetScale, FaunaDB, and Prisma.
- Cloudflare’s own D1, a serverless SQL-based database.
Connect to a database from a Worker
There are three ways to connect to a database from a Worker:
- Database Integrations: Simplifies authentication by managing credentials on your behalf and includes support for PlanetScale, Neon and Supabase.
- TCP Socket API: A direct TCP connection to a database. TCP is the de-facto standard protocol that many databases, such as PostgreSQL and MySQL, use for client connectivity.
- HTTP- or WebSocket-based serverless drivers: Many hosted databases support a HTTP or WebSocket API to enable either clients to connect from environments that do not support TCP, or as their preferred connection protocol.
- Learn how to connect to an existing PostgreSQL database.
- Discover other storage options available for use with Workers.
- Create your first database with Cloudflare D1.