Rivet.Attributes
0.34.3
dotnet add package Rivet.Attributes --version 0.34.3
NuGet\Install-Package Rivet.Attributes -Version 0.34.3
<PackageReference Include="Rivet.Attributes" Version="0.34.3" />
<PackageVersion Include="Rivet.Attributes" Version="0.34.3" />
<PackageReference Include="Rivet.Attributes" />
paket add Rivet.Attributes --version 0.34.3
#r "nuget: Rivet.Attributes, 0.34.3"
#:package Rivet.Attributes@0.34.3
#addin nuget:?package=Rivet.Attributes&version=0.34.3
#tool nuget:?package=Rivet.Attributes&version=0.34.3
<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 typesclient/for generated client modulesrivet.tsfor 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.tsvalidators.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:
- contract-driven APIs with
[RivetContract] - minimal API hosts
- OpenAPI emission and OpenAPI import
- the TypeScript-first sibling project rivet-ts
Documentation
Start with:
License
MIT
| Product | Versions 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. |
-
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 |