Subscribe to receive notifications of new posts:

Build and Deploy Functions to Cloudflare’s 152+ Data Centers with Serverless


2 min read

We’re very excited to announce that Cloudflare Workers are now integrated into the Serverless framework as a serverless cloud provider! Serverless’ open source framework has become a must-have for many developers, and we want to make it as simple as possible to harness the power of Cloudflare’s distributed computing network.

Workers have become essential to the way people build applications on the web. The expressiveness of modern JavaScript combined with sub-30 second deploys to Cloudflare’s network of 152+ datacenters means that you can truly build your application into our global compute network. Up until this point, deploying Workers required doing all of your editing through our browser-based IDE or developing one’s own custom tooling on top of our API. But many developers have their own environments and are already familiar with the Serverless framework, so it seemed natural that we build first-class support for Workers into Serverless!

You can now define the entire structure and routing behavior of your Workers scripts in code and deploy them with ease using serverless deploy from your own development environment. Store configuration files in version control alongside your application code. And feel more confident testing your application with serverless invoke, a new way to quickly send requests to endpoints of interest with specific arguments and headers.

What is Serverless?

Serverless is a paradigm for building applications without concern for the underlying infrastructure. It lets developers focus on writing code and lets them deploy quickly and cheaply to a cloud provider which manages servers, networking, and configuration.

The Serverless framework takes this a step further. It empowers developers to write applications with consistent tooling and project structure, which speeds up development and simplifies deployment to common cloud providers.

Our new plugin lets you use serverless command line tool, which you may already be accustomed to, but with Cloudflare Workers! Define the structure of your Worker in serverless.yml and serverless deploy it to our 152+ data centers around the world.

How simple is it? Here’s a complete serverless.yml for a Slackbot running on Workers. Serverless uses the idea of functions (as in functions-as-service) to separate concerns within an application. For Workers, a function is your application, and the script field refers to the name of your Worker script locally on disk.

    name: slack-bot

  name: cloudflare

  - serverless-cloudflare-workers

    worker: slackbot
    script: bot

Learn how retrieve your Cloudflare account and zone IDs

To deploy your new Worker, simply run serverless deploy or serverless deploy -f SlackBot.

Getting Started

$ npm install -g serverless
$ serverless create --template cloudflare-workers --path new-project
$ cd new-project
$ npm install
$ export [email protected]
$ serverless deploy

Enterprise Features

Use the cloudflare-workers-enterprise template if you're on an enterprise plan in order to deploy multiple scripts to Workers.

Learn More

Interested? Get started by reading the docs.

Looking to build even more powerful Workers? Check out the recipes on the docs about including NPM modules in your project and performing additional routing within your functions.

Are you building something cool with Workers? Let us know!

If you are in the San Francisco Bay Area, and are interested in hearing from Bay Area serverless experts and explorers, you're invited to come by tonight's Serverless Meetup. RSVP here! Doors open at 6.

We protect entire corporate networks, help customers build Internet-scale applications efficiently, accelerate any website or Internet application, ward off DDoS attacks, keep hackers at bay, and can help you on your journey to Zero Trust.

Visit from any device to get started with our free app that makes your Internet faster and safer.

To learn more about our mission to help build a better Internet, start here. If you're looking for a new career direction, check out our open positions.
ServerlessCloudflare WorkersCloudflare NetworkData CenterDevelopersDeveloper Platform

Follow on X


Related posts

May 30, 2024 1:00 PM

Disrupting FlyingYeti's campaign targeting Ukraine

In April and May 2024, Cloudforce One employed proactive defense measures to successfully prevent Russia-aligned threat actor FlyingYeti from launching their latest phishing campaign targeting Ukraine...