Menu

Using the Rust Runtime with Vercel functions

Last updated January 16, 2026

The Rust runtime is available in Beta on all plans

Use Rust to build high-performance, memory-safe serverless functions. The Rust runtime runs on Fluid compute for optimal performance and lower latency.

  1. Configure your project - Add a Cargo.toml file with required dependencies
  2. Create your function - Write handlers in the api/ directory
  3. Deploy - Push to GitHub or use the Vercel CLI

Create a Cargo.toml file in your project root:

Cargo.toml
[package]
name = "rust-hello-world"
version = "0.1.0"
edition = "2024"
 
[dependencies]
tokio = { version = "1", features = ["full"] } # async runtime
vercel_runtime = { version = "2" } # handles communicating with Vercel's function bridge
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
 
# Each handler has to be specified as [[bin]]
# Note that you need to provide unique names for each binary
[[bin]]
name = "hello"
path = "api/hello.rs"
 
# This section configures settings for the release profile, which optimizes the build for performance.
[profile.release]
codegen-units = 1
lto = "fat"
opt-level = 3

Create Rust files in your api/ directory. Each file becomes a serverless function:

api/hello.rs
use serde_json::{Value, json};
use vercel_runtime::{Error, Request, run, service_fn};
 
#[tokio::main]
async fn main() -> Result<(), Error> {
    let service = service_fn(handler);
    run(service).await
}
 
async fn handler(_req: Request) -> Result<Value, Error> {
    Ok(json!({
        "message": "Hello, world!",
    }))
}

For more code examples, please refer to our templates:

vercel/examples.

Push your code to a connected GitHub repository for automatic deployments.

Deploy directly using the Vercel CLI:

vercel deploy

For prebuilt deployments, optimize your .vercelignore:

.vercelignore
# Ignore everything in the target directory except for release binaries
target/**
!target/release
!target/x86_64-unknown-linux-gnu/release/**
!target/aarch64-unknown-linux-gnu/release/**
Rust Runtime feature support table
Feature
Rust Runtime

Fluid compute

Active CPU

Streaming

waitUntil

Logs

Request metrics

Was this helpful?

supported.