CommunityToolkit.Aspire.SurrealDb
13.1.1
Prefix Reserved
See the version list below for details.
dotnet add package CommunityToolkit.Aspire.SurrealDb --version 13.1.1
NuGet\Install-Package CommunityToolkit.Aspire.SurrealDb -Version 13.1.1
<PackageReference Include="CommunityToolkit.Aspire.SurrealDb" Version="13.1.1" />
<PackageVersion Include="CommunityToolkit.Aspire.SurrealDb" Version="13.1.1" />
<PackageReference Include="CommunityToolkit.Aspire.SurrealDb" />
paket add CommunityToolkit.Aspire.SurrealDb --version 13.1.1
#r "nuget: CommunityToolkit.Aspire.SurrealDb, 13.1.1"
#:package CommunityToolkit.Aspire.SurrealDb@13.1.1
#addin nuget:?package=CommunityToolkit.Aspire.SurrealDb&version=13.1.1
#tool nuget:?package=CommunityToolkit.Aspire.SurrealDb&version=13.1.1
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.1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.1)
- OpenTelemetry.Extensions.Hosting (>= 1.12.0)
- SurrealDb.Net (>= 0.9.0)
-
net8.0
- Microsoft.Extensions.Configuration.Binder (>= 10.0.1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.1)
- OpenTelemetry.Extensions.Hosting (>= 1.12.0)
- SurrealDb.Net (>= 0.9.0)
-
net9.0
- Microsoft.Extensions.Configuration.Binder (>= 10.0.1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.1)
- 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.2.1-beta.532 | 37 | 3/13/2026 |
| 13.2.1-beta.531 | 44 | 3/11/2026 |
| 13.2.1-beta.528 | 36 | 3/5/2026 |
| 13.1.2-beta.518 | 51 | 2/17/2026 |
| 13.1.2-beta.516 | 53 | 2/9/2026 |
| 13.1.2-beta.515 | 50 | 2/2/2026 |
| 13.1.2-beta.514 | 53 | 1/30/2026 |
| 13.1.2-beta.513 | 54 | 1/29/2026 |
| 13.1.2-beta.512 | 55 | 1/29/2026 |
| 13.1.2-beta.511 | 55 | 1/28/2026 |
| 13.1.2-beta.509 | 60 | 1/20/2026 |
| 13.1.2-beta.508 | 49 | 1/19/2026 |
| 13.1.2-beta.507 | 54 | 1/19/2026 |
| 13.1.2-beta.506 | 57 | 1/16/2026 |
| 13.1.2-beta.505 | 50 | 1/16/2026 |
| 13.1.2-beta.504 | 53 | 1/16/2026 |
| 13.1.1 | 124 | 1/16/2026 |
| 13.1.1-beta.502 | 55 | 1/16/2026 |
| 13.1.0 | 101 | 1/14/2026 |
| 13.1.0-beta.499 | 56 | 1/14/2026 |