SharpNinja.Valhalla: an embedded, in-process C# port of the Valhalla OSM routing engine
I've been porting Valhalla (the open-source OSM routing engine used by projects like Mapbox's earlier stack) to C# and just shipped 1.1.0.
This project does a complete reimplementation in C# to allow executing the navigation engine on device. You point it at a local Valhalla tile directory (built by stock Valhalla or built on-device from an .osm.pbf extract using this library's own tile builder) and it computes routes entirely in-process. Useful if you want turn-by-turn routing embedded directly in a desktop or mobile .NET app instead of standing up (or calling out to) a routing service.
What's ported, module for module against the upstream C++:
Baldr(graph tile reader)Midgard(geometry/polylines)Loki(location correlation)Sif(costing: auto + truck)Thor(bidirectional A*)Odin(maneuvers + en-US narrative prose)Mjolnir(tile builder: OSM PBF parsing, graph construction, shortcuts, restrictions).
Quickstart:
services.AddSingleton<EmbeddedValhallaGraphReaderFactory>();
services.AddSingleton<IOsmTileDirectoryProvider>(new FixedTileDirectoryProvider("/path/to/valhalla_tiles"));
services.AddSingleton<IOsmRoutingClient, EmbeddedValhallaRoutingClient>();
var result = await client.CalculateRouteAsync(new OsmRouteRequest(
Endpoint: null,
Origin: new GeoCoordinate(47.6062, -122.3321),
Destination: new GeoCoordinate(45.5152, -122.6784),
Costing: OsmRouteCostings.Auto));
As of 1.1.0 it does maneuver narrative prose (en-US) and bidirectional alternate routes; earlier versions had those as known gaps and I closed both this release.
MIT licensed, matching upstream. Targets net10.0.
- GitHub: https://github.com/sharpninja/valhalla-dotnet
- NuGet: https://www.nuget.org/packages/SharpNinja.Valhalla
Happy to answer questions about the port, or about doing something like this for other C/C++ engines in general.
Posted Jul 11, 2026, 1:43 PM UTC