CommunityToolkit.Aspire.SurrealDb
13.0.0
Prefix Reserved
dotnet add package CommunityToolkit.Aspire.SurrealDb --version 13.0.0
NuGet\Install-Package CommunityToolkit.Aspire.SurrealDb -Version 13.0.0
<PackageReference Include="CommunityToolkit.Aspire.SurrealDb" Version="13.0.0" />
<PackageVersion Include="CommunityToolkit.Aspire.SurrealDb" Version="13.0.0" />
<PackageReference Include="CommunityToolkit.Aspire.SurrealDb" />
paket add CommunityToolkit.Aspire.SurrealDb --version 13.0.0
#r "nuget: CommunityToolkit.Aspire.SurrealDb, 13.0.0"
#:package CommunityToolkit.Aspire.SurrealDb@13.0.0
#addin nuget:?package=CommunityToolkit.Aspire.SurrealDb&version=13.0.0
#tool nuget:?package=CommunityToolkit.Aspire.SurrealDb&version=13.0.0
CommunityToolkit.Aspire.SurrealDb
Registers a SurrealDbClient in the DI container for connecting to a SurrealDB instance.
Getting started
Prerequisites
- SurrealDB cluster.
Install the package
Install the .NET Aspire SurrealDB Client library with NuGet:
dotnet add package CommunityToolkit.Aspire.SurrealDb
Usage example
In the Program.cs file of your project, call the AddSurrealClient extension method to register a SurrealDbClient for use via the dependency injection container. The method takes a connection name parameter.
builder.AddSurrealClient("surreal");
Configuration
The .NET Aspire SurrealDB Client integration provides multiple options to configure the server connection based on the requirements and conventions of your project.
Use a connection string
When using a connection string from the ConnectionStrings configuration section, you can provide the name of the connection string when calling builder.AddSurrealClient():
builder.AddSurrealClient("surreal");
And then the connection string will be retrieved from the ConnectionStrings configuration section:
{
"ConnectionStrings": {
"surreal": "Server=ws://127.0.0.1:8000/rpc;Namespace=test;Database=test;Username=root;Password=root"
}
}
Use configuration providers
The .NET Aspire SurrealDB Client integration supports Microsoft.Extensions.Configuration. It loads the SurrealDbClientSettings from configuration by using the Aspire:Surreal:Client key. Example appsettings.json that configures some of the options:
{
"Aspire": {
"Surreal": {
"Client": {
"Options": {
"Endpoint": "ws://127.0.0.1:8000/rpc",
"Namespace": "test",
"Database": "test",
"Username": "root",
"Password": "root"
}
}
}
}
}
Use inline delegates
Also you can pass the Action<SurrealDbClientSettings> configureSettings delegate to set up some or all the options inline, for example to set the API key from code:
builder.AddSurrealDbClient("surreal", settings => settings.Options.Endpoint = "ws://localhost:8000/rpc");
AppHost extensions
In your AppHost project, install the CommunityToolkit.Aspire.Hosting.SurrealDb library with NuGet:
dotnet add package CommunityToolkit.Aspire.Hosting.SurrealDb
Then, in the Program.cs file of AppHost, register a SurrealDB cluster and consume the connection using the following methods:
var db = builder.AddSurrealServer("surreal")
.AddNamespace("ns")
.AddDatabase("db");
var myService = builder.AddProject<Projects.MyService>()
.WithReference(db);
The WithReference method configures a connection in the MyService project named db. In the Program.cs file of MyService, the SurrealDB connection can be consumed using:
builder.AddSurrealClient("db");
Then, in your service, inject SurrealDbClient and use it to interact with the SurrealDB instance:
public class MyService(SurrealDbClient client)
{
// ...
}
Additional documentation
- https://github.com/surrealdb/surrealdb.net
- https://learn.microsoft.com/dotnet/aspire/community-toolkit/hosting-surrealdb
Feedback & contributing
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- OpenTelemetry.Extensions.Hosting (>= 1.12.0)
- SurrealDb.Net (>= 0.9.0)
-
net8.0
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- OpenTelemetry.Extensions.Hosting (>= 1.12.0)
- SurrealDb.Net (>= 0.9.0)
-
net9.0
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- OpenTelemetry.Extensions.Hosting (>= 1.12.0)
- SurrealDb.Net (>= 0.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 13.0.0 | 166 | 11/25/2025 |
| 13.0.0-beta.462 | 115 | 11/25/2025 |
| 13.0.0-beta.456 | 122 | 11/23/2025 |
| 13.0.0-beta.454 | 74 | 11/23/2025 |
| 13.0.0-beta.453 | 95 | 11/22/2025 |
| 13.0.0-beta.450 | 101 | 11/22/2025 |
| 13.0.0-beta.448 | 103 | 11/22/2025 |
| 13.0.0-beta.444 | 331 | 11/17/2025 |
| 13.0.0-beta.443 | 246 | 11/17/2025 |
| 13.0.0-beta.440 | 83 | 11/15/2025 |
| 13.0.0-beta.439 | 219 | 11/12/2025 |
| 13.0.0-beta.438 | 219 | 11/12/2025 |
| 13.0.0-beta.436 | 219 | 11/12/2025 |
| 13.0.0-beta.435 | 223 | 11/11/2025 |
| 13.0.0-beta.433 | 140 | 11/10/2025 |
| 13.0.0-beta.432 | 145 | 11/10/2025 |
| 13.0.0-beta.431 | 131 | 11/6/2025 |
| 13.0.0-beta.430 | 139 | 11/6/2025 |
| 9.9.0 | 186 | 11/3/2025 |
| 9.9.0-beta.427 | 134 | 11/3/2025 |
| 9.8.1-beta.426 | 137 | 11/3/2025 |
| 9.8.1-beta.424 | 127 | 10/28/2025 |
| 9.8.1-beta.420 | 129 | 10/27/2025 |
| 9.8.1-beta.419 | 119 | 10/27/2025 |
| 9.8.1-beta.417 | 127 | 10/27/2025 |
| 9.8.1-beta.414 | 123 | 10/24/2025 |
| 9.8.1-beta.413 | 126 | 10/22/2025 |
| 9.8.1-beta.410 | 126 | 10/16/2025 |
| 9.8.1-beta.408 | 114 | 10/16/2025 |
| 9.8.1-beta.407 | 118 | 10/16/2025 |
| 9.8.1-beta.406 | 126 | 10/15/2025 |
| 9.8.0 | 185 | 9/26/2025 |
| 9.8.0-beta.405 | 121 | 10/15/2025 |
| 9.8.0-beta.404 | 126 | 10/13/2025 |
| 9.8.0-beta.402 | 135 | 9/29/2025 |
| 9.8.0-beta.401 | 126 | 9/29/2025 |
| 9.8.0-beta.399 | 129 | 9/26/2025 |
| 9.8.0-beta.398 | 132 | 9/25/2025 |
| 9.8.0-beta.397 | 127 | 9/25/2025 |
| 9.8.0-beta.395 | 125 | 9/24/2025 |
| 9.8.0-beta.394 | 128 | 9/23/2025 |
| 9.8.0-beta.393 | 132 | 9/23/2025 |
| 9.8.0-beta.392 | 127 | 9/23/2025 |
| 9.8.0-beta.389 | 254 | 9/18/2025 |
| 9.8.0-beta.388 | 259 | 9/16/2025 |
| 9.8.0-beta.386 | 210 | 9/15/2025 |
| 9.8.0-beta.385 | 204 | 9/15/2025 |
| 9.8.0-beta.384 | 50 | 9/13/2025 |
| 9.8.0-beta.376 | 130 | 9/8/2025 |
| 9.8.0-beta.375 | 60 | 9/6/2025 |
| 9.8.0-beta.373 | 142 | 9/5/2025 |
| 9.8.0-beta.372 | 139 | 9/4/2025 |
| 9.8.0-beta.370 | 131 | 9/2/2025 |
| 9.8.0-beta.364 | 127 | 9/1/2025 |
| 9.7.2 | 219 | 8/29/2025 |
| 9.7.2-beta.362 | 180 | 8/29/2025 |
| 9.7.2-beta.361 | 177 | 8/29/2025 |
| 9.7.2-beta.360 | 177 | 8/29/2025 |
| 9.7.2-beta.359 | 181 | 8/28/2025 |
| 9.7.2-beta.358 | 172 | 8/28/2025 |
| 9.7.2-beta.357 | 176 | 8/28/2025 |
| 9.7.1 | 240 | 8/27/2025 |
| 9.7.1-beta.355 | 175 | 8/27/2025 |
| 9.7.1-beta.354 | 174 | 8/27/2025 |
| 9.7.1-beta.353 | 177 | 8/27/2025 |
| 9.7.1-beta.352 | 174 | 8/27/2025 |
| 9.7.1-beta.351 | 182 | 8/27/2025 |
| 9.7.1-beta.348 | 132 | 8/14/2025 |
| 9.7.1-beta.344 | 79 | 8/10/2025 |
| 9.7.1-beta.343 | 208 | 8/8/2025 |
| 9.7.1-beta.342 | 211 | 8/7/2025 |
| 9.7.1-beta.341 | 215 | 8/6/2025 |
| 9.7.1-beta.340 | 196 | 8/5/2025 |
| 9.7.1-beta.339 | 194 | 8/5/2025 |
| 9.7.0 | 130 | 8/1/2025 |
| 9.7.0-beta.337 | 92 | 8/1/2025 |
| 9.7.0-beta.336 | 111 | 8/1/2025 |
| 9.7.0-beta.335 | 105 | 8/1/2025 |