Rivet.Attributes 0.34.3

dotnet add package Rivet.Attributes --version 0.34.3
                    
NuGet\Install-Package Rivet.Attributes -Version 0.34.3
                    
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="Rivet.Attributes" Version="0.34.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rivet.Attributes" Version="0.34.3" />
                    
Directory.Packages.props
<PackageReference Include="Rivet.Attributes" />
                    
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 Rivet.Attributes --version 0.34.3
                    
#r "nuget: Rivet.Attributes, 0.34.3"
                    
#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 Rivet.Attributes@0.34.3
                    
#: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=Rivet.Attributes&version=0.34.3
                    
Install as a Cake Addin
#tool nuget:?package=Rivet.Attributes&version=0.34.3
                    
Install as a Cake Tool

<p align="center"> <h1 align="center">Rivet</h1> <p align="center"> <a href="https://www.nuget.org/packages/Rivet.Attributes"><img src="https://img.shields.io/nuget/v/Rivet.Attributes?label=Rivet.Attributes" alt="NuGet" /></a> <a href="https://www.nuget.org/packages/dotnet-rivet"><img src="https://img.shields.io/nuget/v/dotnet-rivet?label=dotnet-rivet" alt="NuGet" /></a> <a href="https://github.com/maxanstey-meridian/rivet/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License" /></a> </p> </p>

End-to-end type safety between .NET and TypeScript. Use your C# types and ASP.NET endpoints as the source of truth for generated TypeScript types, a typed client, and optional Zod validators.

Rivet maps what actually survives the wire boundary: no drift, no handwritten TS mirrors, no schema language you need to learn first.

oRPC gives you this when your server is TypeScript. Rivet gives you the same DX when your server is .NET.

Install

dotnet add package Rivet.Attributes
dotnet tool install --global dotnet-rivet

Generate

dotnet rivet --project path/to/Api.csproj --output ./generated

By default this emits:

  • types/ for generated TypeScript types
  • client/ for generated client modules
  • rivet.ts for runtime configuration and fetch helpers

C# Types → TS Types

public enum WorkItemStatus { Draft, Open, InProgress, Review, Done, Cancelled }

public sealed record Email(string Value);

public sealed record MemberDto(Guid Id, string Name, Email Email, string Role);

public sealed record CreateTaskResult(Guid Id, DateTime CreatedAt);
export type WorkItemStatus =
  | "draft"
  | "open"
  | "inProgress"
  | "review"
  | "done"
  | "cancelled";

export type Email = string & { readonly __brand: "Email" };

export type MemberDto = {
  id: string;
  name: string;
  email: Email;
  role: string;
};

export type CreateTaskResult = {
  id: string;
  createdAt: string;
};

ASP.NET Endpoints → Typed Client

Rivet works with ordinary ASP.NET controllers. Mark the endpoints you want to surface to TypeScript and generate a client from the real transport shape.

// Server-side DTOs and the annotated ASP.NET endpoint.
public enum WorkItemStatus { Draft, Open, InProgress, Review, Done, Cancelled }

public sealed record TaskDetailDto(
    string Title,
    WorkItemStatus Status,
    List<string> Labels,
    string? Description);

public sealed record NotFoundDto(string Message);

[ApiController]
[Route("api/tasks")]
public sealed class TasksController : ControllerBase
{
    [RivetEndpoint]
    [HttpGet("{id:guid}")]
    [ProducesResponseType(typeof(TaskDetailDto), StatusCodes.Status200OK)]
    [ProducesResponseType(typeof(NotFoundDto), StatusCodes.Status404NotFound)]
    public async Task<IActionResult> Get(Guid id, CancellationToken ct)
    {
        return Ok(default(TaskDetailDto));
    }
}

Rivet generates the matching TypeScript DTOs and client overloads:

// Generated from the C# DTOs above.
export type TaskDetailDto = {
  title: string;
  status: WorkItemStatus;
  labels: string[];
  description?: string | null;
};

export type NotFoundDto = {
  message: string;
};

// Status-aware result shape for the non-throwing flow.
export type GetResult = RivetResultOf<
  | { status: 200; data: TaskDetailDto; response: Response }
  | { status: 404; data: NotFoundDto; response: Response }
  | { status: Exclude<number, 200 | 404>; data: unknown; response: Response }
>;

export function get(input: { params: { id: string; }; }): Promise<TaskDetailDto>;
export function get(
  input: { params: { id: string; }; },
  opts: { unwrap: false },
): Promise<GetResult>;

Use the generated client in either throwing or status-aware mode:

import { tasks } from "./generated/client/index.js";
import { configureRivet } from "./generated/rivet.js";

// Configure the generated client once at app startup.
configureRivet({ baseUrl: "https://api.example.com" });

// Fully type-safe, throws on error.
const task = await tasks.get({ params: { id: taskId } });

// Set `unwrap: false` when you want the full status-aware union instead of throwing.
const result = await tasks.get({ params: { id: taskId } }, { unwrap: false });
if (result.isNotFound()) {
  console.error(result.data.message);
}

Runtime Validation

dotnet rivet --project path/to/Api.csproj --output ./generated --compile

With validation enabled, generated clients automatically validate incoming responses with Zod at the network boundary.

  • schemas.ts
  • validators.ts
import { fromJSONSchema } from "zod";
import { TaskDetailDtoSchema } from "./schemas.js";
import type { TaskDetailDto } from "./types/controllers.js";

// Generated once from the emitted JSON Schema.
const _assertTaskDetailDto = fromJSONSchema(TaskDetailDtoSchema);

// Generated validation helper for use anywhere.
export const assertTaskDetailDto = (data: unknown): TaskDetailDto =>
  _assertTaskDetailDto.parse(data) as TaskDetailDto;

Advanced Features

Rivet also supports:

Documentation

Start with:

License

MIT

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

    • No dependencies.

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
0.34.3 99 5/22/2026
0.34.2 97 5/11/2026
0.34.1 92 5/11/2026
0.34.0 97 4/21/2026
0.33.2 107 4/16/2026
0.33.1 99 4/16/2026
0.33.0 100 4/15/2026
0.32.4 103 4/14/2026
0.32.3 102 4/8/2026
0.32.2 99 4/7/2026
0.32.1 92 4/7/2026
0.32.0 92 4/7/2026
0.31.0 98 4/6/2026
0.30.0 103 3/30/2026
0.29.0 103 3/30/2026
0.28.0 97 3/29/2026
0.27.0 99 3/24/2026
0.26.0 96 3/23/2026
0.25.0 94 3/23/2026
0.24.0 97 3/21/2026
Loading failed