A production-ready ASP.NET Core adapter for building modern Inertia.js applications with .NET.
InertiaCore.AspNetCore provides a complete server-side integration layer for Inertia.js, enabling you to build modern monolithic applications using your preferred frontend framework while keeping the simplicity of server-side routing and controllers.
Supports:
- ASP.NET Core MVC
- ASP.NET Core Minimal APIs
- Inertia.js v3
- Vue, React, and other Inertia-compatible frontend frameworks
This project is based on the original InertiaCore project by Kacper Ziubryniewicz.
InertiaCore brings the Inertia.js server adapter experience to the .NET ecosystem.
It provides:
- A complete Inertia request/response pipeline
- Server-side rendering support
- Lazy and async props
- Shared application data
- Validation error handling
- Vite integration
- Asset version management
- Protocol-compliant redirects
- Minimal API support
No separate API layer is required. Build your application with server-side routing and modern frontend components.
✅ Full support for the latest Inertia.js v3 protocol.
Includes:
- Inertia request detection
- Version handling
- Partial reloads
- Lazy props
- Shared props
- Redirect handling
- Error bag support
- Response formatting
Supported application styles:
✅ MVC Controllers
public IActionResult Index()
{
return Inertia.Render("Dashboard");
}✅ Minimal APIs
app.MapGet("/dashboard", () =>
{
return Inertia.Render("Dashboard");
});Automatic validation handling using ASP.NET Core ModelState.
Features:
- Automatic validation error collection
- Named validation error bags
X-Inertia-Error-Bagsupport- Standardized string array error responses
Example:
{
"errors": {
"default": {
"email": [
"The email field is required."
]
}
}
}Share data globally across all Inertia responses.
Example:
Inertia.Share("auth", new
{
UserId = userId
});or:
Inertia.Share(new Dictionary<string, object?>
{
["auth"] = new
{
UserId = userId
}
});Load expensive data only when required.
Example:
public IActionResult Index()
{
return Inertia.Render("Posts", new
{
Posts = new LazyProp(async () =>
{
return await _context.Posts.ToListAsync();
})
});
}Built-in support for Inertia SSR.
Enable SSR:
builder.Services.AddInertia(options =>
{
options.SsrEnabled = true;
});Configure your SSR endpoint:
builder.Services.AddInertia(options =>
{
options.SsrUrl = "http://127.0.0.1:13714/render";
});Includes helpers for Vite-powered applications.
Register:
builder.Services.AddViteHelper();Use in your layout:
@Vite.Input("src/main.ts")React HMR support:
@Vite.ReactRefresh()Flexible version resolution support.
Built-in providers:
- Default static version provider
- Delegate-based version provider
- Custom provider implementations
Example:
builder.Services.AddInertia(options =>
{
options.VersionResolver = () =>
{
return "1.0.0";
};
});Automatically handles Inertia-compliant redirects.
Supports:
- GET redirects
- POST redirects
- PUT redirects
- PATCH redirects
- DELETE redirects
Non-GET requests automatically use 303 See Other.
Empty responses from Inertia requests are automatically converted into redirects.
Handled scenarios:
return Ok();return NoContent();The adapter redirects users back to the previous page using:
- The
Refererheader - Current request URL fallback
Install from NuGet:
Install-Package InertiaCore.AspNetCoredotnet add package InertiaCore.AspNetCoreAdd Inertia services:
using InertiaCore.Extensions;
builder.Services.AddInertia();Add middleware:
app.UseInertia();Your application is now ready to serve Inertia responses.
Create your root view.
Example:
Views/App.cshtml
@using InertiaCore
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title inertia>
My Application
</title>
@await Inertia.Head(Model)
</head>
<body>
@await Inertia.Html(Model)
<script type="module" src="/src/main.ts"></script>
</body>
</html>Render an Inertia page:
public IActionResult Index()
{
return Inertia.Render("Dashboard", new
{
User = user
});
}Customize Inertia:
builder.Services.AddInertia(options =>
{
options.RootView = "~/Views/App.cshtml";
options.SsrEnabled = true;
options.SsrUrl =
"http://127.0.0.1:13714/render";
});Example projects:
Upcoming improvements:
- Additional Inertia protocol coverage
- Improved developer tooling
- More ASP.NET Core integrations
- Additional examples and templates
Contributions, issues, and feature requests are welcome.
Please open an issue or submit a pull request.
Licensed under the MIT License.
See LICENSE for details.