This repository contains the C#, Unity and Godot client SDKs for SpacetimeDB. These SDKs contain all the tools you need to build native clients for SpacetimeDB modules using C#.
The Unity SDK uses the same code as the C# SDK. You can find the documentation for the C# SDK in the C# SDK Reference. For a guided tutorial, see the C# SDK Quickstart.
There is also a comprehensive Unity tutorial/demo available:
- Unity Tutorial Doc
- Unity Demo Repo
The Godot SDK uses the same code as the C# SDK. You can find the documentation for the C# SDK in the C# SDK Reference. For a guided tutorial, see the C# SDK Quickstart.
There is also a comprehensive Godot tutorial/demo available:
- Godot Tutorial Doc
- Godot Demo Repo
See DEVELOP.md.
C#, Unity, and Godot clients can opt in with .WithAutomaticReconnect() on the connection builder, optionally passing AutomaticReconnectOptions with MinDelay and MaxDelay to tune the backoff. The SDK recovers lost connections, retains cached rows and subscription handles, and replays subscriptions in one batch. Keep calling FrameTick() during outages; Unity's SpacetimeDBNetworkManager does this automatically. Register subscriptions and row callbacks once, in OnConnect or after Build(). OnConnect runs only on the first successful connection; .OnAutomaticReconnect((conn, identity, token) => ...) runs after each successful recovery, before subscription replay. Subscription OnApplied runs again once the cache is reconciled.
For expiring credentials, supply the initial token with .WithToken(initialToken) and add .WithTokenProvider(() => RefreshTokenAsync()). The provider obtains a token for the same identity before a reconnect when needed. If you persist tokens, save them from both OnConnect and OnAutomaticReconnect. Initial connection failures do not retry, and Disconnect() stops recovery. Handle Status.UnknownResult for pending reducer calls whose outcome was lost; the SDK does not repeat them.
See the C# SDK Reference for retry callbacks, token refresh, and subscription behavior, or the reconnect test application for runnable scenarios.