Generally, Cloudflare Workers can be written locally, deployed with serverless, and tested with the serverless invoke
command. However, using the Cloudflare Workers Playground can help you test and view your worker’s results live if you need more insight while developing your Cloudflare Worker.
Below is a list of general tips for developing Cloudflare Workers with Serverless.
Write your functions
Use serverless deploy
only when you've made changes to serverless.yml
and in CI/CD systems.
Use serverless deploy -f myFunction
to rapidly deploy changes when you are working on a specific Cloudflare Workers Function.
Use serverless invoke -f myFunction
to test your Cloudflare Workers Functions.
A handy list of commands to use when developing with the Serverless Framework.
Creates a new Service:
serverless create -p [SERVICE NAME] -t cloudflare-workers
Use this when you have made changes to your Functions, Events or Resources in serverless.yml
or you simply want to deploy all changes within your Service at the same time.
serverless deploy
Use this to quickly overwrite your Cloudflare Workers Functions, allowing you to develop faster if you have an Enterprise account that supports deploying multiple functions.
serverless deploy -f [FUNCTION NAME]
Invokes a Cloudflare Workers Function.
serverless invoke -f [FUNCTION NAME]
Product