URL Shortener

Tools like Cloudflare Workers and Firebase make building scalable web applications much more straightforward. I’ve built a URL shortener before, but I didn’t maintain it, and I knew there was a better way. I like using Firebase because it simplifies authentication.


Since Firebase handles all the authentication and authorization, it accelerates development time by a lot. The Firestore rules are always a little complicated for me, but I figure it out after a lot of trial and error. This setup allows me to read and write to the Firestore database quickly. I use a simple Cloud Function to retrieve the URL for the short URL.


The Worker is simple too! It just looks at the URL, calls the Firebase Cloud Function, then redirects the visitor to the long URL. With Workers, it is easy to cache a Fetch request.


I like using Parcel and Preact. Parcel makes bundling the project so much easier than webpack. Preact is a fast and lightweight alternative to React. This build is so simple that I wrote all of the CSS. I would typically use Tailwindcss.