docs/docs/00100-intro/00200-quickstarts/00600-c-sharp.md
import { InstallCardLink } from "@site/src/components/InstallCardLink"; import { StepByStep, Step, StepText, StepCode } from "@site/src/components/Steps";
Get a SpacetimeDB C# app running in under 5 minutes.
This will start the local SpacetimeDB server, compile and publish your module, and generate C# client bindings.
</StepText>
<StepCode>
spacetime dev --template basic-cs
</StepCode>
Edit `spacetimedb/Lib.cs` to add tables and reducers. Use the generated bindings in the client project.
</StepText>
<StepCode>
my-spacetime-app/
├── spacetimedb/ # Your SpacetimeDB module
│ ├── StdbModule.csproj
│ └── Lib.cs # Server-side logic
├── client.csproj
├── Program.cs # Client application
└── module_bindings/ # Auto-generated types
</StepCode>
Tables store your data. Reducers are functions that modify data — they're the only way to write to the database.
</StepText>
<StepCode>
using SpacetimeDB;
public static partial class Module
{
[SpacetimeDB.Table(Accessor = "Person", Public = true)]
public partial struct Person
{
public string Name;
}
[SpacetimeDB.Reducer]
public static void Add(ReducerContext ctx, string name)
{
ctx.Db.Person.Insert(new Person { Name = name });
}
[SpacetimeDB.Reducer]
public static void SayHello(ReducerContext ctx)
{
foreach (var person in ctx.Db.Person.Iter())
{
Log.Info($"Hello, {person.Name}!");
}
Log.Info("Hello, World!");
}
}
</StepCode>
spacetime call add Alice
"Alice"
spacetime call say_hello
spacetime logs 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 [C# SDK Reference](../../00200-core-concepts/00600-clients/00600-csharp-reference.md) for detailed API docs