The metadata plugin allows applications to obtain certain information about their runtime environment.


To use the metadata plugin, add shuttle-metadata to the dependencies of your project by manually editing the project’s Cargo.toml file or by invoking cargo add shuttle-metadata from the command line.

Once the metadata plugin dependency is available to your project, use the resource by annotating your main function with the shuttle_metadata::ShuttleMetadata attribute.


This snippet shows an Axum main function, annotated with the shuttle_metadata::ShuttleMetadata attribute.
use axum::{routing::get, Router};
use shuttle_metadata::Metadata;

async fn axum(
    #[shuttle_metadata::ShuttleMetadata] metadata: Metadata,
) -> shuttle_axum::ShuttleAxum {
    let router = Router::new().route("/", get(format!("{:?}", metadata)));


This example has one route which returns the debug print of the Metadata struct:

DeploymentMetadata { env: Local, project_name: ProjectName("metadata-axum-app"), service_name: "metadata-axum-app", storage_path: ".shuttle-storage" }

The full example can also be found on GitHub.