Create a Rocket project

Create a new binary crate:

$ cargo new rocket-example --bin
$ cd rocket-example

Add rocket as a dependency:

# Cargo.toml


+ rocket = { version = "^0.5.0-rc.2", features = ["json"] }


Pay attention to the version that you're using. rocket and/or its dependencies may not compile on the stable build of the Rust compiler if an early version of rocket is used.

The following should compile and run:

fn main() {
// src/

use rocket::*;

async fn index() -> &'static str {
    "Hello, bakeries!"

#[launch] // The "main" function of the program
fn rocket() -> _ {
    rocket::build().mount("/", routes![index])


To verify it works:

$ cargo run
GET localhost:8000/

"Hello, bakeries!"