YARP Docsv2.3
Docs/Getting started/Getting started with YARP

Getting started with YARP

Add YARP to a new ASP.NET Core project and forward every request to a single backend in a few lines of code.

Prerequisites

The .NET SDK, and a backend server to forward requests to - any HTTP server will do for testing, including another ASP.NET Core app running locally.

Create the project

Create an empty ASP.NET Core project and add the Yarp.ReverseProxy package:

Create and add the package

From an empty folder.

.NET CLIdotnet new web -o MyProxy
cd MyProxy
dotnet add package Yarp.ReverseProxy

Configure the proxy

Register the reverse proxy and load its configuration from appsettings.json:

Program.cs

Registers the proxy and maps its routes.

C#var builder = WebApplication.CreateBuilder(args);

builder.Services.AddReverseProxy()
    .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));

var app = builder.Build();
app.MapReverseProxy();
app.Run();
Note

See Configuration files for the full appsettings.json shape - a route and a cluster with at least one destination.

Run it

Start the app with dotnet run and send a request to the proxy's URL - it forwards to your configured destination and relays the response back, unchanged.

Adapted from Microsoft Learn , licensed under CC BY 4.0 .