docs/versioned_docs/version-1.12.0/00100-intro/00200-quickstarts/00500-rust.md
import { InstallCardLink } from "@site/src/components/InstallCardLink"; import { StepByStep, Step, StepText, StepCode } from "@site/src/components/Steps";
Get a SpacetimeDB Rust app running in under 5 minutes.
This will start the local SpacetimeDB server, compile and publish your module, and generate Rust client bindings.
</StepText>
<StepCode>
spacetime dev --template basic-rs my-spacetime-app
</StepCode>
Edit `spacetimedb/src/lib.rs` to add tables and reducers. Use the generated bindings in `client/src/module_bindings/` to build your client.
</StepText>
<StepCode>
my-spacetime-app/
├── spacetimedb/ # Your SpacetimeDB module
│ ├── Cargo.toml
│ └── src/
│ └── lib.rs # Server-side logic
├── client/ # Client application
│ ├── Cargo.toml
│ └── src/
│ ├── main.rs
│ └── module_bindings/ # Auto-generated types
└── README.md
</StepCode>
Tables store your data. Reducers are functions that modify data — they're the only way to write to the database.
</StepText>
<StepCode>
use spacetimedb::{ReducerContext, Table};
#[spacetimedb::table(name = person, public)]
pub struct Person {
name: String,
}
#[spacetimedb::reducer]
pub fn add(ctx: &ReducerContext, name: String) {
ctx.db.person().insert(Person { name });
}
#[spacetimedb::reducer]
pub fn say_hello(ctx: &ReducerContext) {
for person in ctx.db.person().iter() {
log::info!("Hello, {}!", person.name);
}
log::info!("Hello, World!");
}
</StepCode>
"Alice"
spacetime call my-spacetime-app say_hello
spacetime logs my-spacetime-app 2025-01-13T12:00:00.000000Z INFO: Hello, Alice! 2025-01-13T12:00:00.000000Z INFO: Hello, World!
</StepCode>
</Step>
</StepByStep>
## Next steps
- See the [Chat App Tutorial](../00300-tutorials/00100-chat-app.md) for a complete example
- Read the [Rust SDK Reference](../../00200-core-concepts/00600-client-sdk-languages/00500-rust-reference.md) for detailed API docs