A Rust server-side app in a Cloudflare Worker

submited by
Style Pass
2022-05-21 20:00:07

Rust is extraordinarily portable. This post is the first of many describing how a Rust server-side app can be integrated with multiple platforms.

Note, you don't need to create a separate library for the app, but I'll be referencing the next section in future blog posts where I'll integrate the same app into various platforms.

We're going to create a small portion of a note taking app. We'll create the index route which will render a list of notes. The app uses an API to persists notes, makes calls to the API with surf, and uses askama for templating. Feel free to view the complete source code or try out the demo.

Run the Cloudflare worker with wrangler dev. You should see some HTML with a Notes heading and a few links above it. This isn't the complete app, but you can try the demo and view source for the complete app.

It'd be pretty easy to create a much more complex app with all the perks of Rust and it's ecosystem. Since this just compiles to WASM, we could also run this app in the browser. I'll have another post on that. Integrating Cloudflare's recently announced D1 SQL database would allow for a complete full-stack app.

Leave a Comment