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

External Services

Many external services provide libraries and SDKs to interact with their APIs. While many Node-compatible libraries work on Workers right out of the box, some, which implement fs, http/net, or access the browser window do not directly translate to the Workers runtime, which is v8-based.

For a list of working packages, refer to Works on Workers.

​​ Authentication

If your service 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;

Then use the secret value to authenticate with the external service. For example, if the external service requires an API key for authentication, include the secret in your library’s configuration.

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

Use Custom Domains when communicating with external APIs, which treat your Worker as your core application.