Skip to main content

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" (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

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 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

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

litestar_vite-0.23.3.tar.gz (508.2 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.23.3-py3-none-any.whl (268.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: litestar_vite-0.23.3.tar.gz
  • Upload date:
  • Size: 508.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for litestar_vite-0.23.3.tar.gz
Algorithm Hash digest
SHA256 8af9018fe56f5808f8c394fddb0fde82b0751c83afe7bb53f78994edf234f1ad
MD5 f705eae376f974516da6d213a3f43be1
BLAKE2b-256 03c9f6e5d87ff71cb99e340c9d36c79ec7f9cb2531ca71b8ef0be7a2b3b09c1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_vite-0.23.3.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.23.3-py3-none-any.whl.

File metadata

  • Download URL: litestar_vite-0.23.3-py3-none-any.whl
  • Upload date:
  • Size: 268.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for litestar_vite-0.23.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e65bc335acddd6d6028ab5e8b9a3a61118805d04b80f775c419e84b9bfbcc6a6
MD5 459e4766253615ea7eb4f20f3fd3b78b
BLAKE2b-256 97b0392c3329b6bc9b14bd8bee17e65230f2c9d5f2b5451b8ae6712026f87235

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_vite-0.23.3-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.

Supported by

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