NATS.Client.JetStream 2.0.0-alpha.2

Prefix Reserved
This is a prerelease version of NATS.Client.JetStream.
There is a newer version of this package available.
See the version list below for details.
dotnet add package NATS.Client.JetStream --version 2.0.0-alpha.2
                    
NuGet\Install-Package NATS.Client.JetStream -Version 2.0.0-alpha.2
                    
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="NATS.Client.JetStream" Version="2.0.0-alpha.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NATS.Client.JetStream" Version="2.0.0-alpha.2" />
                    
Directory.Packages.props
<PackageReference Include="NATS.Client.JetStream" />
                    
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 NATS.Client.JetStream --version 2.0.0-alpha.2
                    
#r "nuget: NATS.Client.JetStream, 2.0.0-alpha.2"
                    
#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 NATS.Client.JetStream@2.0.0-alpha.2
                    
#: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=NATS.Client.JetStream&version=2.0.0-alpha.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=NATS.Client.JetStream&version=2.0.0-alpha.2&prerelease
                    
Install as a Cake Tool

NATS.NET V2

Preview

The NATS.NET V2 client is in preview and not recommended for production use. Codebase is still under heavy development and currently we only have implementations for core NATS features.

Please test and provide feedback by visiting our Slack channel.

NATS.NET V2 Goals

  • Only support Async I/O
  • Target latest .NET LTS Release (currently net6.0)

Packages

  • NATS.Client.Core: core NATS
  • NATS.Client.Hosting: extension to configure DI container
  • NATS.Client.JetStream: JetStream not yet implemented

Basic Usage

Download the latest nats-server for your platform and run it without any arguments. nats-server will listen on its default TCP port 4222.

Given that we have a plain class Bar, we can publish and subscribe to our nats-server sending and receiving Bar objects:

public record Bar
{
    public int Id { get; set; }
    public string Name { get; set; }
}

Subscribe to all bar related subjects:

await using var nats = new NatsConnection(options);

await using sub = await nats.SubscribeAsync<Bar>("bar.>");
await foreach (var msg in sub.Msgs.ReadAllAsync())
{
    Console.WriteLine($"Received {msg.Subject}: {msg.Data}\n");
}

Publish Bar objects to related bar subjects:

await using var nats = new NatsConnection();

for (int i = 0; i < 10; i++)
{
    Console.WriteLine($" Publishing {i}...");
    await nats.PublishAsync<Bar>($"bar.baz.{i}", new Bar { Id = i, Name = "Baz" });
}

You should also hook your logger to NatsConnection to make sure all is working as expected or to get help diagnosing any issues you might have:

var options = NatsOpts.Default with { LoggerFactory = new MinimumConsoleLoggerFactory(LogLevel.Error) };
await using var nats = new NatsConnection(options);

Contributing

  • Run dotnet format at root directory of project in order to clear warnings that can be auto-formatted

Attribution

This library is based on the excellent work in Cysharp/AlterNats

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (24)

Showing the top 5 NuGet packages that depend on NATS.Client.JetStream:

Package Downloads
NATS.Client.KeyValueStore

Key/Value Store for NATS .NET, built on JetStream. Provides distributed key-value storage with watch, history, and TTL support.

NATS.Client.ObjectStore

Object Store for NATS .NET, built on JetStream. Stores and retrieves large objects as chunked streams with metadata and integrity checks.

NATS.Net

NATS .NET client for the NATS cloud-native messaging system. Includes Core NATS pub/sub, JetStream persistent messaging, Key/Value Store, Object Store, and Services. Built on async/await with support for .NET 8, .NET 6, and .NET Standard 2.0/2.1.

Savvyio.App

Provides a complete and convenient set of API additions for building a DDD, CQRS and Event Sourcing enabled .NET application using Microsoft Dependency Injection, Microsoft Entity Framework Core, Dapper, AWS SNS/SQS, Azure Queue Storage/Azure Event Grid and RabbitMQ Worker Queue/Publish-Subscribe.

K4os.NatsTransit

Message bus built on top of NATS

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0-preview.6 240 5/14/2026
3.0.0-preview.5 144 5/7/2026
3.0.0-preview.4 959 5/1/2026
3.0.0-preview.3 1,281 4/17/2026
3.0.0-preview.2 2,353 3/13/2026
3.0.0-preview.1 869 2/18/2026
2.8.0 16,353 5/13/2026
2.8.0-preview.3 73 5/6/2026
2.8.0-preview.2 211 5/1/2026
2.8.0-preview.1 191 4/16/2026
2.7.3 302,818 3/13/2026
2.7.2 277,818 2/10/2026
2.7.2-preview.2 1,280 1/30/2026
2.7.2-preview.1 1,454 1/14/2026
2.7.1 136,925 1/8/2026
2.7.0 62,036 12/19/2025 2.7.0 is deprecated.
2.7.0-preview.8 4,578 10/20/2025
2.6.14 24,453 12/17/2025
2.6.12 28,786 12/11/2025
2.0.0-alpha.2 191 9/7/2023
Loading failed