Serverless Typescript, Rust and Go running in one repo on Netlify

By edisch, 6 October, 2021

With Netlify's new support for serverless Rust and Go, and native Typescript (no need to precompile to JS) I wanted to see what it would take to get all 3 running at the same time for a single Netlify site.

The documentation is still lacking on how to pull this off. At the moment you have to sift through the source of netlify/cli to find out how to get it working but once you do it's pretty darn cool! Here you can see an example repository with all 3 languages setup. The functions work locally via netlify dev and build just fine up on Netlify when you're ready to deploy them.

The magic comes from the two new environment variables that enable the experimental support for building any Rust or Go functions included in the functions directory. NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE=true will enable compilation of a Rust binary to run as a serverless function and similarly NETLIFY_EXPERIMENTAL_BUILD_GO_SOURCE=true will enable compilation of a Go binary to run as a serverless function.

If you take a peek at the automated tests for Rust and Go support you get a better idea of how these features are supposed to work. With this level of integration it's easy to move functions between languages and pick the right tool for the job. If your function is getting slow or needs some space or compute complexity optimization you can pop into Rust and start hacking away. Welcome to the future everyone. Thanks Netlify!🎉

Author
Topic