Write less, do more at the edge: Introducing expressly

Don't you ever wish Compute@Edge worked like the framework you already know? We just launched expressly, a lightweight and minimalist routing layer for JavaScript apps running on Fastly's Compute@Edge, and inspired by the popular Node.js framework, Express.

Because Compute@Edge is low level, developers can iterate on top of it with libraries like this very quickly, in their preferred language. My colleague Kailan did something similar recently with a library for Edge Side Includes in Rust.

expressly lets you focus on your business logic, and makes it easier than ever to get started with Compute@Edge in JavaScript. It’s packed with lots of useful features:

Write less, do more

My colleagues will attest that little brings me more joy than deleting lots of code. As I was rewriting some code examples on Fastly’s Developer Hub using expressly, I found myself increasingly more joyful.

To give you a taste of what it’s like to write Compute@Edge apps with expressly, I’ve contrived an application scenario with the following requirements: 

  1. On requests to /base64/[something]:

    1. read a segment of the URL path;

    2. write it into a cookie;

    3. decode it and put it in the response body;

    4. return a 500 status if decoding fails, and include the error message in the response body;

  2. Forward all requests to /status/[anything] to an origin; 

  3. Send either 405 (Method Not Allowed) or 404 (Not Found) responses in any other case, as appropriate. 

Let’s take a look at how you might implement this without expressly:

…and another look at the same application logic, this time using expressly:

Isn’t that delightful? Expressly’s route matcher, built-in path parameter parser, and default error-handling middleware make light work of complex scenarios like the one I imagined. You simply must try it for yourself!

Getting started with expressly

If you don't have Node.js and a JavaScript Compute@Edge service set up yet, start by getting set up.

Install expressly

Install expressly from the npm registry:

npm i @fastly/expressly

Your first expressly app

Replace the contents of your Compute@Edge app's src/index.js with the following:

import { Router } from "@fastly/expressly";
const router = new Router();
router.get("/", async (req, res) => {
return res.send("Hello world!");

Try it out

Start your app locally:

fastly compute serve

This will start your service on http://localhost:7676.


@fastly/expressly@1.0.0-alpha.x is currently available for developer testing. Check out our growing collection of code examples using expressly on Fastly’s Developer Hub for more inspiration.

If you want to try this for yourself, clone the second fiddle in this blog post and test it out with your own origin without creating a Fastly account. When you’re ready to publish a full global service, you can sign up for a free trial of Compute@Edge and get started with expressly right away.

Dora Militaru
Developer Relations Engineer

2 min read

Want to continue the conversation?
Schedule time with an expert
Share this post
Dora Militaru
Developer Relations Engineer

Dora is a developer relations engineer at Fastly. She cut her developer teeth on building a global news website and cultivated her compassion by leading data protection and site reliability engineering teams. Working at a tiny kitchen table in London, she dreams of helping others build a faster, more secure, more reliable — and better — web for everyone.

Ready to get started?

Get in touch or create an account.