Litestar Vite connects the Litestar backend to a Vite toolchain. It supports SPA, Template, and Inertia flows, and can proxy Vite dev traffic through your ASGI port or run Vite directly.
VITE_PROXY_MODE=direct.public/manifest.json (configurable) and serves under asset_url.@hey-api/openapi-ts via the Vite plugin.pip install litestar-vite
litestar assets install # installs frontend deps via configured executor
from litestar import Litestar
from litestar_vite import VitePlugin, ViteConfig
app = Litestar(plugins=[VitePlugin(config=ViteConfig(dev_mode=True))])
litestar run # starts Litestar; Vite dev is proxied automatically
from litestar import Litestar
from litestar.contrib.jinja import JinjaTemplateEngine
from litestar.template.config import TemplateConfig
from litestar_vite import VitePlugin, ViteConfig
app = Litestar(
template_config=TemplateConfig(engine=JinjaTemplateEngine(directory="templates")),
plugins=[VitePlugin(config=ViteConfig(mode="template", dev_mode=True))],
)
Requires session middleware.
from litestar import Litestar
from litestar.middleware.session.server_side import ServerSideSessionConfig, ServerSideSessionMiddleware
from litestar_vite import VitePlugin, ViteConfig
from litestar_vite.inertia import InertiaPlugin
from litestar_vite.inertia.config import InertiaConfig
app = Litestar(
middleware=[ServerSideSessionMiddleware(config=ServerSideSessionConfig(secret="secret"))],
plugins=[
VitePlugin(config=ViteConfig(mode="template", inertia=True, dev_mode=True)),
InertiaPlugin(InertiaConfig()),
],
)
VitePlugin(config=ViteConfig(types=True)) # enable exports
litestar assets generate-types # one-off or CI
litestar assets doctor — diagnose/fix configlitestar assets init --template react|vue|svelte|... — scaffold frontendlitestar assets build / serve — build or watchlitestar assets deploy --storage gcs://bucket/assets — upload via fsspeclitestar assets generate-types — OpenAPI + routes → TS typeslitestar assets install — install frontend deps with the configured executor--fix can rewrite simple vite.config values (assetUrl, bundleDirectory, hotFile, type paths) after creating a backup.examples/ (basic, inertia, spa-react)