I know most of us just want to dive into development when we see new tool or framework. But then there is so many comebacks for things that we need to do at the beginning. In this post I will describe my working environment for development of Workers.
IDE (Integrated Development Environment)
I usually use Visual Studio Code. It has great extension library but you don’t need anything special for now. You can download it here. https://code.visualstudio.com/
Quick Installation of Wrangler
npm i @cloudflare/wrangler -g
That is for installation but you need to configure your environment for publishing. The configuration file is created in a
.wrangler directory in your computer's home directory. You need to add account email and global API Key to this file.
email = "email[at]example.com"
api_key = "XXXXXKEYXXXXXXX"
You can get your API Key from CF Dashboard. Go to Dashboard>Profile>API Tokens and get ‘ Global API Key’.
Generate From Template
After these quick installations and configurations you can generate your first workers app. I recommend to use template for understand path structure and configurations.
This command on terminal will create first basic workers app for you. It actually clones this GitHub repo. https://github.com/cloudflare/worker-template But it is enough for a start.
There are 3 main files in our folder now. index.js, wrangler.toml and package.json.
package.json is your main configuration file for workers app. You can add version, name of your app, depended packages or change main file name on this file.
wrangler.toml is configuration of environments and deployment. You can define type of your app, route configuration, zone info, KV info, etc. here.
After these steps you are all set to start development of workers app. You may start with Playground if you like to start simple and don’t want to set up anything.