Getting Started with Faasta

Follow this guide to deploy your first function in minutes

1

Install the Faasta CLI

Start by installing the Faasta CLI tool using cargo:

cargo install cargo-faasta

This will install the cargo-faasta subcommand that you'll use to create, build, and deploy your functions.

2

Login with GitHub

Authenticate with your GitHub account to deploy functions:

cargo faasta login

This will open a browser window to authenticate with GitHub. Once authenticated, you'll be able to deploy functions to Faasta.

3

Create a New Function

Create a new Faasta function project:

cargo faasta new my-function

This will generate a new directory with a basic Faasta function template. Alternatively, you can initialize an existing directory:

mkdir my-function
cd my-function
cargo faasta init
4

Customize Your Function

Edit the src/lib.rs file to customize your function:

use spin_sdk::http::{IntoResponse, Response};
use spin_sdk::http_component;

#[http_component]
fn hello_world(req: http::Request<()>) -> anyhow::Result<impl IntoResponse> {
    Ok(Response::builder()
        .status(200)
        .header("content-type", "text/plain")
        .body("Hello from Faasta!")
        .build())
}
5

Build Your Function

Build your function for WebAssembly:

cargo faasta build

This compiles your Rust code to a WebAssembly module that can be deployed to Faasta.

6

Deploy Your Function

Deploy your function to Faasta:

cargo faasta deploy

Once deployed, your function will be available at https://my-function.faasta.xyz (where "my-function" is the name of your function).

Next Steps

Now that you've deployed your first function, you can:

  • Explore the documentation to learn more about Faasta's features
  • Check out example functions for inspiration
  • Try integrating with other services using HTTP requests
  • Set up your own self-hosted Faasta instance