Use the following steps to install InertiaCore on your machine.
- .NET 6.0 or higher
- Node.js 18.0 or higher
You can use one of our starter kits to get started quickly.
npx @inertiacore/create@latest
You will be asked to enter a project name and to select the front-end library you want to use.
This will create a new project with the name you provide.
You can choose between a React or Vue project.
Once you have created the project, you can run it using the following commands.
Run the following command to start the dotnet development server:
dotnet run
In another terminal, run the following command to start the React or Vue development server:
cd ClientApp
npm run dev
This will start the development server and you can access the application at http://localhost:5266
or https://localhost:7266
if you are using HTTPS.
You need to add few lines to the Program.cs
or Starup.cs
file.
using InertiaCore.Extensions;
[...]
builder.Services.AddInertia();
[...]
app.UseInertia();
Create a file /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 App</title>
</head>
<body>
@await Inertia.Html(Model)
<script src="/js/app.js"></script>
</body>
</html>
You can change the root view file using:
builder.Services.AddInertia(options =>
{
options.RootView = "~/Views/Main.cshtml";
});