This is a very simple URL shortening services running on Cloudflare Workers using Cloudflare KV to store URL data
- Clone the repo
- If you don't have it installed, install the
wrangler cli
- Login to your Cloudflare account via
wrangler login
- Deploy via
wrangler publish
- In the Cloudflare Workers dashboard, create a new KV namespace (you can freely choose a name at this time)
- Open the deployed worker and in the Settings tab, bind the created namespace to the
route
variable
- Disable the
workers.dev
endpoint and link it to a domain (eg. route.example.com)
In the Cloudflare Workers dashboard, open the KV namespace you just created and for each URL you want to be shortened add an entry in the table (eg. if you insert hello
as the key and https://example.com
as the value, calling https://WORKERENDPOINT/hello
will redirect you to https://example.com
)
- It's easy to setup
- The free tier has 100k requests per day (which is a lot!)
- Runs on the global Cloudflare Network
- Took 12 lines of code to create this service (could take even less)