Cloudflare Docs
Workers
Visit Workers on GitHub
Set theme to dark (⇧+D)

Databases

Use Cloudflare Workers to connect your application to external databases, such as Postgres, MySQL, FaunaDB, Supabase, MongoDB Atlas, PlanetScale, Prisma, and more. To use these Cloudflare Workers integrations, you need to install the relevant packages for the databases you want to use.

Once you have installed the necessary packages, use the APIs provided by these packages to connect to your database and perform operations on it. Refer to detailed links for service-specific instructions.

​​ Authentication

If your database requires authentication, use Wrangler secrets to securely store your credentials. To do this, create a secret in your Cloudflare Workers project using the following wrangler secret command:

wrangler secret put SECRET_NAME

Then, retrieve the secret value in your code using the following code snippet:

const secretValue = env.SECRET_NAME;

Use the secret value to authenticate with the external service. For example, if the external service requires an API key or database username and password for authentication, include these in using the relevant service’s library or API.

For services that require mTLS authentication, use mTLS certificates to present a client certificate.