i almost wrote this blog awhile ago when i was first going to check out the edge. i’m fully onboard with it now and smolder when it’s not well supported, i’ll rationalize why i’m fully sold
what does edge computing mean
for me, it’s the ability to deploy some code to a CDN that executes very close to the user.
i find it’s easy to think of them like a cascade of callbacks.
what are you actually using it for?
i am putting myself through pain to use them as my first answer to every node project lately.
- graphql servers
- rest api servers
- discord bots
- webhook callbacks
i feel like i can iteterate a lot faster using them while skipping the whole “deploying my service” part of hosting apis and i love it
why not use them everywhere
there are critical limitation to be aware of. you can’t use every npm pacakge you are familiar with, but i find you can still use a lot. the simplest way to tell usually is to try deploying a project
if something doesn’t work, there are alternatives i argue are better. for example, express
won’t cleanly deploy to many edge platforms, but i would argue hono
is something developers who want to use the modern JS ecosystem will prefer learning about options that are not only new, but faster and designed by developers who use the same tools today.
how do you use it
right now my platform of choice for hobby projects is Cloudflare Workers. generous free tier, and if i were to commercialize them i would certainly love to have the paid tier features but i don’t find them critical.
A project that mimics express looks as simple as this:
import { Hono } from "hono"
const hono = new Hono();
hono.get("/hello", c => c.text("World 🗺️"))
export default hono;
you can then deploy your example in this case with a simple command
bun run wrangler deploy
takes usually under a few seconds, and you get nice preview urls you can assign to your cloudflare dns later.
if you test the url like this you should see “World” returned, and extremely quickly.
curl https://example.com/hello
World 🗺️