Installation¶
Install litestar-vite and set up Inertia.js for your frontend framework.
See also
Official Inertia.js docs: Installation
Backend Setup¶
Install the Python package:
pip install litestar-vite
uv add litestar-vite
pdm add litestar-vite
Frontend Setup¶
Install the Inertia.js client and litestar-vite-plugin:
npm install @inertiajs/react litestar-vite-plugin
npm install @inertiajs/vue3 litestar-vite-plugin
npm install @inertiajs/svelte litestar-vite-plugin
Or use project scaffolding:
# Scaffold a complete Inertia project
litestar assets init --template react-inertia
litestar assets init --template vue-inertia
litestar assets init --template svelte-inertia
Minimal Configuration¶
from litestar import Litestar, get
from litestar_vite import ViteConfig, VitePlugin
@get("/", component="Home")
async def home() -> dict:
return {"message": "Welcome!"}
app = Litestar(
route_handlers=[home],
plugins=[
VitePlugin(config=ViteConfig(
dev_mode=True,
inertia=True, # Enables Inertia with defaults
)),
],
)
The inertia=True shortcut enables Inertia with sensible defaults.
For custom configuration, see Configuration.
See Also¶
Configuration - Full configuration reference
Inertia.js - Framework-specific setup (React, Vue, Svelte)