Convex.Client.Extensions.DependencyInjection 3.0.0-alpha

This is a prerelease version of Convex.Client.Extensions.DependencyInjection.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Convex.Client.Extensions.DependencyInjection --version 3.0.0-alpha
                    
NuGet\Install-Package Convex.Client.Extensions.DependencyInjection -Version 3.0.0-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Convex.Client.Extensions.DependencyInjection" Version="3.0.0-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Convex.Client.Extensions.DependencyInjection" Version="3.0.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Convex.Client.Extensions.DependencyInjection" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Convex.Client.Extensions.DependencyInjection --version 3.0.0-alpha
                    
#r "nuget: Convex.Client.Extensions.DependencyInjection, 3.0.0-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Convex.Client.Extensions.DependencyInjection@3.0.0-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Convex.Client.Extensions.DependencyInjection&version=3.0.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Convex.Client.Extensions.DependencyInjection&version=3.0.0-alpha&prerelease
                    
Install as a Cake Tool

Convex.Client.Extensions.DependencyInjection

Dependency Injection extensions for the Convex .NET Client, providing simplified configuration and registration patterns for .NET applications.

Installation

dotnet add package Convex.Client.Extensions.DependencyInjection

Features

  • Simple Registration: AddConvex() extension methods for IServiceCollection
  • Configuration Support: Bind configuration from appsettings.json or environment variables
  • Named Clients: Support for multiple Convex deployments with IConvexClientFactory
  • Typed Clients: Strongly-typed client configuration patterns
  • Auto-Configuration: Automatic client builder setup with sensible defaults

Quick Start

Basic Usage

using Convex.Client.Extensions.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);

// Simple registration with inline options
builder.Services.AddConvex(options =>
{
    options.DeploymentUrl = "https://happy-animal-123.convex.cloud";
    options.EnableAutoReconnect = true;
    options.MaxReconnectAttempts = 5;
});

var app = builder.Build();

Configuration from appsettings.json

{
  "Convex": {
    "DeploymentUrl": "https://happy-animal-123.convex.cloud",
    "EnableAutoReconnect": true,
    "MaxReconnectAttempts": 5,
    "ReconnectDelayMs": 1000
  }
}
builder.Services.AddConvex(builder.Configuration.GetSection("Convex"));

Using IConvexClient in Your Services

public class ChatService
{
    private readonly IConvexClient _client;

    public ChatService(IConvexClient client)
    {
        _client = client;
    }

    public async Task<List<Message>> GetMessagesAsync()
    {
        return await _client.Query<List<Message>>("messages:list")
            .ExecuteAsync();
    }
}

Named Clients

// Registration
builder.Services.AddConvex("primary", options =>
{
    options.DeploymentUrl = "https://primary-deployment.convex.cloud";
});

builder.Services.AddConvex("secondary", options =>
{
    options.DeploymentUrl = "https://secondary-deployment.convex.cloud";
});

// Usage
public class MultiDeploymentService
{
    private readonly IConvexClient _primaryClient;
    private readonly IConvexClient _secondaryClient;

    public MultiDeploymentService(IConvexClientFactory factory)
    {
        _primaryClient = factory.CreateClient("primary");
        _secondaryClient = factory.CreateClient("secondary");
    }
}

Configuration Options

Option Type Default Description
DeploymentUrl string required Convex deployment URL
EnableAutoReconnect bool true Enable automatic reconnection
MaxReconnectAttempts int 5 Maximum reconnection attempts
ReconnectDelayMs int 1000 Delay between reconnection attempts (ms)
EnableLogging bool true Enable logging integration

Benefits vs. Manual Registration

Before (Manual Registration)

services.AddSingleton<IConvexClient>(sp =>
{
    var logger = sp.GetRequiredService<ILogger<ConvexClient>>();
    var deploymentUrl = configuration["Convex:DeploymentUrl"];

    return new ConvexClientBuilder()
        .UseDeployment(deploymentUrl!)
        .WithLogging(logger)
        .WithAutoReconnect(maxAttempts: 5, delayMs: 1000)
        .Build();
});

After (With Extensions)

services.AddConvex(configuration.GetSection("Convex"));

Result: 50% less boilerplate code, improved readability, and standardized configuration patterns.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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

Initial release (0.0.1) providing dependency injection extensions for simplified Convex client configuration and registration. See CHANGELOG.md for full details.