Vite plugin for Litestar
Project description
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 by default; switch to two-port with
VITE_PROXY_MODE=direct. - Framework-mode support: use
mode="framework"(aliasmode="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 underasset_url. - Type-safe frontends: optional OpenAPI/routes export plus
@hey-api/openapi-tsvia the Vite plugin. - Inertia support: stable v2 protocol with session middleware, optional script-element bootstrap, and optional SSR.
Install
pip install litestar-vite
npm install litestar-vite-plugin
Quick Start
import os
from pathlib import Path
from litestar import Litestar
from litestar_vite import PathConfig, ViteConfig, VitePlugin
DEV_MODE = os.getenv("VITE_DEV_MODE", "true").lower() in ("true", "1", "yes")
app = Litestar(
plugins=[VitePlugin(config=ViteConfig(
dev_mode=DEV_MODE,
paths=PathConfig(root=Path(__file__).parent),
))]
)
litestar assets init --template vue
litestar assets install
litestar run --reload
Documentation
- Usage Guide: Core concepts, configuration, and type generation.
- Inertia: Fullstack protocols and SSR.
- Frameworks: Guides for React, Vue, Svelte, Angular, Astro, and Nuxt.
- Reference: API and CLI documentation.
For a full list of changes, see the Changelog.
Common Commands
litestar assets init --template <name>: scaffold a frontend or framework applitestar assets install: install frontend dependencies with the configured executorlitestar assets build: build production assetslitestar assets serve: run the frontend toolchain directlylitestar assets generate-types: export OpenAPI, routes, and Inertia page-prop metadatalitestar 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.
For Inertia script-element bootstrap, enable InertiaConfig(use_script_element=True) on the Python side and keep createInertiaApp({ defaults: { future: { useScriptElementForInitialPage: true } } }) aligned in the browser entry and SSR entry when ssr=True is enabled.
Links
- Docs: https://litestar-org.github.io/litestar-vite/latest/
- Examples:
examples/(React, Vue, Svelte, HTMX, Inertia, Astro, Nuxt, SvelteKit, Angular) - Real-world example: litestar-fullstack
- Issues: https://github.com/litestar-org/litestar-vite/issues/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file litestar_vite-0.20.0.tar.gz.
File metadata
- Download URL: litestar_vite-0.20.0.tar.gz
- Upload date:
- Size: 444.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
524755f64624b0e6a6ee2ef76a419b5c6f57218d2ef8ac6e752ec4b457e5c36c
|
|
| MD5 |
461cb49ef20ffb33973d4a519882872f
|
|
| BLAKE2b-256 |
bf4b03ff3164801b48eebca29e25768fb64fc93a34517d516b7c78171104cd78
|
Provenance
The following attestation bundles were made for litestar_vite-0.20.0.tar.gz:
Publisher:
publish.yml on litestar-org/litestar-vite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
litestar_vite-0.20.0.tar.gz -
Subject digest:
524755f64624b0e6a6ee2ef76a419b5c6f57218d2ef8ac6e752ec4b457e5c36c - Sigstore transparency entry: 1155903891
- Sigstore integration time:
-
Permalink:
litestar-org/litestar-vite@5db5d72cbf1eececd16bb2987ea9e8b734525d4b -
Branch / Tag:
refs/tags/v0.20.0 - Owner: https://github.com/litestar-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5db5d72cbf1eececd16bb2987ea9e8b734525d4b -
Trigger Event:
release
-
Statement type:
File details
Details for the file litestar_vite-0.20.0-py3-none-any.whl.
File metadata
- Download URL: litestar_vite-0.20.0-py3-none-any.whl
- Upload date:
- Size: 244.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8d670586569fd001a839290602728acc065e2c7872c7dd2c938b2be6d525695
|
|
| MD5 |
14f3a57b135f69d76b90914427b8a1d4
|
|
| BLAKE2b-256 |
44453b6f5b2d3e83907c49b5318dece17dde2b31d3d8d6b0681571d6c8cad962
|
Provenance
The following attestation bundles were made for litestar_vite-0.20.0-py3-none-any.whl:
Publisher:
publish.yml on litestar-org/litestar-vite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
litestar_vite-0.20.0-py3-none-any.whl -
Subject digest:
d8d670586569fd001a839290602728acc065e2c7872c7dd2c938b2be6d525695 - Sigstore transparency entry: 1155903902
- Sigstore integration time:
-
Permalink:
litestar-org/litestar-vite@5db5d72cbf1eececd16bb2987ea9e8b734525d4b -
Branch / Tag:
refs/tags/v0.20.0 - Owner: https://github.com/litestar-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5db5d72cbf1eececd16bb2987ea9e8b734525d4b -
Trigger Event:
release
-
Statement type: