Deprecated: Please use the official template instead.
A template for kick starting a Cloudflare worker project.
index.ts
is the content of the Workers script.
To generate using wrangler
wrangler generate projectname https://github.com/kimyvgy/worker-typescript-template
Further documentation for Wrangler can be found here.
Start your dev server with following commands:
yarn install
yarn dev
Open up http://0.0.0.0:8787 and you should be ready to go!
If you don't already have an account, then create a cloudflare account here and after verifying your email address with Cloudflare, go to your dashboard and set up your free custom Cloudflare Workers subdomain.
Once that's done, you should be able to deploy your app:
npm run deploy
Please change KV Namespace's id in wrangler.toml
before deploying. Create a new KV namespace:
wrangler kv:namespace create COUNTER --env production
# output example
✨ Success!
Add the following to your configuration file in your kv_namespaces array under [env.production]:
{ binding = "COUNTER", id = "3f04be9cee4445d29a5a331fee98e78b" }