---
title: "Write Netlify Functions in Rust"
description: "Netlify is launching experimental support for Rust in Netlify Functions, with the same developer experience offered for JavaScript, TypeScript, and Go."
source: "https://www.netlify.com/blog/2021/10/14/write-netlify-functions-in-rust/"
last_updated: "2026-07-15T16:18:03.000Z"
---
[Netlify Functions](/platform/core/functions/) give developers an unrivalled workflow for building the backend of a web application, allowing them to focus on writing the business logic instead of provisioning servers, orchestrating deployments, or navigating verbose configuration.

With an integrated local development experience, it’s possible to make changes to functions with a very short feedback loop, with compilation or build steps taken care of automatically behind the scenes. Developers can even generate a public URL for their local server, allowing colleagues or clients to follow along wherever they are in the world.

Currently, this complete experience is available for [JavaScript](https://docs.netlify.com/functions/build-with-javascript/), [TypeScript](https://docs.netlify.com/functions/build-with-typescript/), and [Go](https://docs.netlify.com/functions/build-with-go/) functions. Today, we’re excited to announce experimental support for Rust in the Netlify Functions offering.

## Enabling the feature

During the experimental period, support for Rust must be enabled on a per-site basis by setting the `NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE` environment variable to `true`. You can do this in the Netlify UI by going to **Site settings** > **Build & deploy** > **Environment**, or using the CLI:

```
netlify env:set NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE true
```

## Creating a function

To create a new Rust function, you can run `cargo init FUNCTION_NAME` from your [configured functions directory](https://docs.netlify.com/functions/configure-and-deploy/#configure-the-functions-folder).

The name you choose for the function determines its endpoint. For example, running `cargo init hello` will create a function which, when deployed, will be accessible on the `/.netlify/functions/hello` endpoint.

Alternatively, you can get a jump-start with the [Netlify CLI](https://ntl.fyi/cli)’s function generator. Run `netlify functions:create --language=rust`, choose a template, and you’ll get a fully working function, ready to be deployed and modified to fit your needs.

(You’ll need Netlify CLI version 6.12.0 or later. Run `npm i -g netlify-cli` to install the latest.)

## Function structure

Every function must include a handler that receives requests and returns responses. This takes shape as a function using the `ApiGatewayProxyRequest` and `ApiGatewayProxyResponse` types from the `aws_lambda_events` crate.

Below is an example of a Rust function that returns a message saying “Hello world”.

```
use aws_lambda_events::event::apigw::{ApiGatewayProxyRequest, ApiGatewayProxyResponse};use aws_lambda_events::encodings::Body;use http::header::HeaderMap;use lambda_runtime::{handler_fn, Context, Error};use log::LevelFilter;use simple_logger::SimpleLogger;
#[tokio::main]async fn main() -> Result<(), Error> {    SimpleLogger::new().with_level(LevelFilter::Info).init().unwrap();
    let func = handler_fn(my_handler);    lambda_runtime::run(func).await?;    Ok(())}
pub(crate) async fn my_handler(event: ApiGatewayProxyRequest, _ctx: Context) -> Result<ApiGatewayProxyResponse, Error> {    let path = event.path.unwrap();
    let resp = ApiGatewayProxyResponse {        status_code: 200,        headers: HeaderMap::new(),        multi_value_headers: HeaderMap::new(),        body: Some(Body::Text("Hello world".to_owned())),        is_base64_encoded: Some(false),    };
    Ok(resp)}
```

To try this function, you can clone [the GitHub repository](https://github.com/netlify/rust-functions-example), or deploy it directly to your Netlify account using the button below.

[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/netlify/rust-functions-example)

## Local development

You can use [Netlify Dev](https://www.netlify.com/platform/core/cli/) to test your functions locally. Run `netlify dev` and open [http://localhost:8888/.netlify/functions/hello](http://localhost:8888/.netlify/functions/hello) in the browser. If you’d like to generate a public URL that is accessible from anywhere, use `netlify dev --live`.

Your function will be rebuilt automatically every time you change a file, so that you and your colleagues can see the changes immediately.

## Deployment

Once you’re happy with your changes, you can commit and push the files to Git. We’ll take care of building and deploying your functions automatically.

Our build system runs `cargo build --release` under the hood. If you’d like to customize the build pipeline, you can do so by [specifying a build command](https://docs.netlify.com/configure-builds/get-started/#basic-build-settings) that builds the functions and places the binaries in the configured functions directory. If you do that, make sure to use `x86_64-unknown-linux-musl` as the build target.

Deploying a function for the first time may take a few minutes, since compiling a binary for release is a time-consuming process. But the build artefacts are cached between builds, so subsequent deploys should be significantly faster.

## Lab goggles required

This feature may change substantially while we fine-tune the implementation. Still, in the spirit of [involving our customers in the development of the product](https://www.netlify.com/blog/2021/03/31/test-drive-netlify-beta-features-with-netlify-labs/), we’re excited to get it in front of _you_ sooner rather than later. Your feedback will help us create the best possible experience for everyone using Netlify.

Happy builds, fellow Rustaceans! 🦀 🥽

### Share

-   [X (fka Twitter)](https://twitter.com/intent/tweet?text=Write Netlify Functions in Rust&url=https://www.netlify.com/blog/2021/10/14/write-netlify-functions-in-rust/)
-   [LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.netlify.com%2Fblog%2F2021%2F10%2F14%2Fwrite-netlify-functions-in-rust%2F)
-   [Facebook](https://www.facebook.com/sharer.php?u=https://www.netlify.com/blog/2021/10/14/write-netlify-functions-in-rust/)
-   [Bluesky](https://bsky.app/intent/compose?text=Write Netlify Functions in Rust+https://www.netlify.com/blog/2021/10/14/write-netlify-functions-in-rust/)

* * *

### Tags

-   [Functions](/blog/tags/functions/)
-   [Serverless](/blog/tags/serverless/)
-   [Rust](/blog/tags/rust/)
-   [Engineering](/blog/tags/engineering/)
-   [Product](/blog/tags/product/)

## Keep reading

![](/images/blog-fallback-thumbnail.svg)

Tools & Services February 18, 2021

[

### Netlify Functions - for an unrivaled serverless workflow

](/blog/2021/02/18/netlify-functions-for-an-unrivaled-serverless-workflow/)

-   ![Profile picture of Phil Hawksworth](/_astro/9cfe2bbe94bcb555ce3ac7683ac7905ad3fd32b1-400x400_Z18H6R1.webp)
    
    Phil Hawksworth
    

![](/images/blog-fallback-thumbnail.svg)

News & Announcements March 31, 2021

[

### Test Drive Netlify Beta Features with Netlify Labs

](/blog/2021/03/31/test-drive-netlify-beta-features-with-netlify-labs/)

-   ![Profile picture of Marisa Morby](/_astro/3f466b84b22560254a2abcb04c9650263907abc2-80x80_1EL0lA.webp)
    
    Marisa Morby
    

## Recent posts

News & Announcements July 14, 2026

[

### More headroom, a lower per-credit rate, and a bill you can predict: introducing new Pro plan tiers

](/blog/new-pro-plan-tiers)

-   ![Profile picture of Gehrig Kunz](/_astro/b4e9f58d914d1334ea70d53ea55a1f26b26f1445-512x512_17SwOI.webp)
    
    Gehrig Kunz
    

News & Announcements July 13, 2026

[

### Netlify inside of Claude Design

](/blog/netlify-inside-of-claude-design)

-   ![Profile picture of Sean Roberts](/_astro/bbf2243f8171dbddd80ab2103622106cef84d125-512x512_Z1d2LKE.webp)
    
    Sean Roberts
    

News & Announcements June 25, 2026

[

### Netlify Functions, designed for Agent Experience

](/blog/netlify-functions-designed-for-agent-experience)

-   ![Profile picture of Eduardo Bouças](/_astro/52958f21e8450baf6d8e60302341a984e220c0cd-512x512_13VDlu.webp)
    
    Eduardo Bouças
    

![](/_astro/3f255b372fa958df35802666ee33b4609b2d71bd-1200x1586_1VtE2D.webp)

### How do the best dev and marketing teams work together?

[Access the report](https://www.netlify.com/reports/2024-leadership-trend-report/access/)