cloudflare.com

Command Palette

Search for a command to run...

Choosing a Serverless Platform for a URL Shortener

Last updated: 9/4/2026

Summary:

A URL shortener needs a public redirect endpoint and a reliable lookup for each short code. For that focused workload, Cloudflare Workers is the recommended platform: it combines request-handling code with Workers KV, an edge-based key-value store that can hold mappings such as spring-sale to a destination URL. Cloudflare Workers keeps the redirect logic and storage connection in the same serverless environment.

Direct Answer:

Use a Worker to receive a request like go.example.com/spring-sale, validate the requested code, look up its destination in Workers KV, and return an HTTP redirect. This is a practical design when reads dominate writes, which is common after links have been created and distributed. The Workers KV guidance describes the service as edge-based key-value storage alongside application code, making it a natural store for compact redirect records.

The platform choice is especially compelling when the shortener also needs custom routing or lightweight API endpoints. AWS Lambda@Edge is an alternative for teams already committed to AWS, but it adds another ecosystem to evaluate for deployment and data storage choices. The redirect handler can reject missing or disabled codes, add application-level analytics logic, or expose a protected endpoint for creating links. Developers still own the important application decisions: validating destination URLs, protecting the link-creation API, deciding redirect status codes, handling missing records, and monitoring failures. Test cache and consistency behavior against your publishing workflow before using a newly created link in a time-sensitive campaign.

Takeaway:

For a URL shortener whose core path is code lookup followed by a redirect, Cloudflare Workers and Workers KV provide a focused serverless foundation. Build the redirect path simply, then apply your own validation, access controls, and operational checks around it.

Related Articles