Skip to main content

Litestar Vite

Litestar Vite connects the Litestar backend to a Vite toolchain. It supports SPA, Template, Inertia, and meta-framework workflows, and it can proxy Vite dev traffic through your ASGI port or run Vite directly.

Features

  • One-port dev: proxies Vite HTTP + WS/HMR through Litestar on a single ASGI port by default.
  • Framework-mode support: use mode="framework" (alias mode="ssr") for Astro, Nuxt, and SvelteKit. Litestar proxies everything except your API routes.
  • Production assets: reads the Vite manifest from public/manifest.json (configurable) and serves under asset_url.
  • Type-safe frontends: optional OpenAPI/routes export plus @hey-api/openapi-ts via the Vite plugin.
  • Inertia support: Inertia v2/v3 protocol support with session middleware, script-element bootstrap by default, and optional SSR.

Install

pip install litestar-vite
npm install litestar-vite-plugin

Quick Start

from litestar import Litestar
from litestar_vite import VitePlugin

app = Litestar(plugins=[VitePlugin()])
litestar assets init --template vue
litestar assets install
litestar run --reload

VitePlugin() detects development and production behavior without manual VITE_DEV_MODE parsing. The effective litestar run --host/--port values are also passed to the frontend environment and .litestar.json bridge.

Optional Granian native static serving

Granian 0.16+ can serve eligible production bundle files before the request enters Python:

from litestar import Litestar
from litestar_granian import GranianPlugin
from litestar_vite import VitePlugin

app = Litestar(
    plugins=[
        VitePlugin(),
        GranianPlugin(static="auto"),
    ]
)

This is an optimization, not a separate application configuration. The Litestar static route stays registered, so Uvicorn and other ASGI servers serve the same files. Granian automatically falls back to Litestar when assets are protected, customized, missing, or otherwise unsafe to intercept.

Native hits bypass ASGI middleware, guards, compression, custom headers, and Python access logging. Keep protected or customized assets on the Litestar fallback path. See the production guide for the server matrix and advanced configuration.

Documentation

Common Commands

  • litestar assets init --template <name>: scaffold a frontend or framework app
  • litestar assets install: install frontend dependencies with the configured executor
  • litestar assets build: build production assets
  • litestar assets serve: run the frontend toolchain directly
  • litestar assets generate-types: export OpenAPI, routes, and Inertia page-prop metadata
  • litestar assets doctor: inspect and optionally repair config drift

Development

# Install Python, docs, and JS dependencies; build package artifacts
make install && make build

# Run an example app
uv run litestar --app-dir examples/vue-inertia assets install
uv run litestar --app-dir examples/vue-inertia run

Replace vue-inertia with any other example app: vue, react, svelte, react-inertia, htmx, angular, astro, nuxt, or sveltekit.

litestar-vite now defaults Inertia apps to script-element bootstrap. Inertia v3 clients use that transport automatically; if you pin Inertia v2, keep createInertiaApp({ defaults: { future: { useScriptElementForInitialPage: true } } }) aligned in the browser entry and SSR entry when ssr=True is enabled, or opt back into the legacy data-page path with InertiaConfig(use_script_element=False).

Links

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

litestar_vite-0.29.1.tar.gz (589.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litestar_vite-0.29.1-py3-none-any.whl (286.2 kB view details)

Uploaded Python 3

File details

Details for the file litestar_vite-0.29.1.tar.gz.

File metadata

  • Download URL: litestar_vite-0.29.1.tar.gz
  • Upload date:
  • Size: 589.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for litestar_vite-0.29.1.tar.gz
Algorithm Hash digest
SHA256 ab2c1e36b0e6b3a89858165248bdc372b164a090d506e8b8ace08c2b261ea64d
MD5 99bfe0f32f3a5801b41a86ee442dbad9
BLAKE2b-256 565e7883cfa239f05bc92c72d846c96f3feaadaa77459e220bd78461206a4a96

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_vite-0.29.1.tar.gz:

Publisher: publish.yml on litestar-org/litestar-vite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file litestar_vite-0.29.1-py3-none-any.whl.

File metadata

  • Download URL: litestar_vite-0.29.1-py3-none-any.whl
  • Upload date:
  • Size: 286.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for litestar_vite-0.29.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae29a82ece8100ffbd0386b352fb357866494a6746d7184b91493cd735868d50
MD5 be0909cfd47dd755a68f602439655e84
BLAKE2b-256 a4032b10a63feccc6879982d21760db29cc7296186c95f67c0e07cd507cb2449

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_vite-0.29.1-py3-none-any.whl:

Publisher: publish.yml on litestar-org/litestar-vite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page