litestar-org/litestar-skills/litestar-vite
Claude Code and agent skill by litestar-org/litestar-skills
- community
Checking that the SKILL.md file is still in the repository.
Auto-activate for litestar_vite, VitePlugin, ViteConfig, PathConfig, TypeGenConfig, vite.config.ts, InertiaConfig, component=, or @inertiajs/*. Not for plain Vite or server-only HTMX.
Install
npx vskill@latest install litestar-org/litestar-skills/litestar-viteSKILL.md
litestar-vite
litestar-vite is the first-party plugin that connects a Vite frontend build pipeline to a Litestar backend. It handles dev-server proxying, HMR coordination, manifest resolution for production assets, and (optionally) end-to-end type generation from Litestar OpenAPI to TypeScript.
The runtime has four canonical modes: spa, template, hybrid, and framework. htmx, inertia, ssr, and ssg are aliases that normalize to those modes. external is a fifth, permanent alias of framework; it still requires an ExternalDevServer.
The plugin pairs with the npm package `litestar-vite-plugin` on the JS side. Python ViteConfig is the source of truth; the generated .litestar.json bridge lets JS config normally keep only litestar({ input: [...] }).
This guidance targets litestar-vite 0.33.0. Features include server-rendered UI component fragments, persistent IPC SSR transports with circuit-breaker fallback, AsyncAPI 3.0 typed channel generation, Vite 7+ support, and single-port development proxying. See Release Updates.
Code Style Rules
- Python: PEP 604 unions (
T | None); consumer Litestar app modules MAY usefrom __future__ import annotations. - TypeScript: strict mode;
defineConfigfromvite; onevite.config.tsper frontend project. - Keep
ViteConfigas the source of truth. Only duplicatebundleDir,hotFile, orassetUrlinvite.config.tsfor deliberate standalone/override workflows. - Inertia (`mode="hybrid"`): use
msgspec.Struct(..., rename="camel")for structured page-prop returns, wirecsrfHeaders()intocreateInertiaApp({ defaults: { visitOptions } }), useuseFormfor mutations, and read flash notifications from top-levelusePage().flash(dict[str, list[str]]), neverusePage().props.flash.
Quick Reference
Minimal SPA setup (Python side)
Minimal SPA setup (JS side)
Mode Selection
| Mode | Use For | Key Setup | |
|---|---|---|---|
spa | React, Vue, Svelte, or Analog-powered Angular SPA with a Litestar JSON API backend | dev_mode=True proxies to Vite; manifest in prod | |
template (htmx alias) | Server-rendered Jinja2/Mako pages and HTMX with Vite-bundled assets | Use TemplateConfig; add litestar-htmx when using HTMX | |
hybrid (inertia alias) | Inertia.js routes returning JS page components | Configure ViteConfig(inertia=InertiaConfig(...)) | |
framework (ssr / ssg aliases) | Nuxt, SvelteKit, Astro, Angular CLI, or another frontend-owned HTML server | Use the framework entry point or ExternalDevServer |
Decision tree:
- Need full SPA with client-side routing → spa
- Server-rendered HTML, sprinkle Vite-bundled JS → template
- HTMX-driven hypermedia with Vite assets → template (
htmxalias) +HTMXPlugin - Server-side routing + JS page components, shared data → hybrid (
inertiaalias; see Inertia Reference) - Nuxt, SvelteKit, or Astro owns HTML → framework
- Angular CLI or another non-Vite server → framework +
ExternalDevServer
VitePlugin config (Python)
enabled=None auto-detects serving contexts and consults VITE_ENABLED. enabled=False leaves VitePlugin.config and asset CLI commands available but skips runtime routes, middleware, static routers, lifespans, and the SPA handler.
Type Generation
| Output | Path | Trigger | Frontend Use | |
|---|---|---|---|---|
openapi.json | output/openapi.json | Whenever OpenAPI schema changes | Source of truth for SDK + schemas | |
routes.json | output/routes.json | Route table changes | Route metadata consumed by the JS plugin | |
routes.ts | output/routes.ts | Route table or app.csrf_config changes | route("name", { params }) typed URL builder + CSRF_COOKIE_NAME / CSRF_HEADER_NAME (0.31.0+) | |
api/ | output/api/ | OpenAPI changes | hey-api types, schemas, SDK, and fetch client | |
schemas.ts | output/schemas.ts | Route request/response changes | FormInput, FormResponse, and SuccessResponse helpers | |
inertia-pages.json | output/inertia-pages.json | Inertia handlers added/changed | Page-prop metadata consumed by the JS plugin | |
page-props.ts | output/page-props.ts | Inertia handlers added/changed | Typed props for Inertia page components | |
static-props.ts | output/static-props.ts | ViteConfig.static_props changes | Typed static bridge values (virtual:litestar-static-props) | |
asyncapi.json | output/asyncapi.json | AsyncAPIPlugin + Channels / WebSocket / SSE route changes (0.32.0+) | AsyncAPI 3.0 document when AsyncAPIPlugin is registered and generate_channels=True | |
channels.ts | output/channels.ts | AsyncAPIPlugin + Channels / WebSocket / SSE route changes (0.32.0+) | ChannelMap consumed by createTypedChannels() |
CLI:
Frontend consumption:
ViteAssetLoader, Secondary HTML Entries, and Component Fragments
Auto-registered Jinja2 globals when a template engine is configured:
| Helper | Use | |
|---|---|---|
{{ vite('resources/main.ts') }} | Render script/link tags for a Vite input; handles dev vs manifest | |
{{ vite_hmr() }} | Inject HMR client <script> in dev mode; no-op in prod | |
{{ vite_static('favicon.svg') }} | Resolve a static asset URL | |
{{ vite_routes() }} | Render inline route metadata for client-side routing | |
{{ vite_fragment('components/Card.vue', props=..., mode='static') }} | Server-render a React/Vue/Svelte/Astro fragment or <litestar-island> (0.32.0+) |
Minimal base template:
For programmatic asset loading (ViteAssetLoader, resolve_html_entry) or server-rendered <litestar-island> UI component fragments (ComponentResponse(..., mode="island")), see Modes and Config.
CLI
assets init --template accepts react, react-router, react-tanstack, react-inertia, react-inertia-jinja, vue, vue-inertia, vue-inertia-ssr, vue-inertia-jinja, vue-inertia-jinja-ssr, svelte, svelte-inertia, svelte-inertia-jinja, sveltekit, nuxt, astro, htmx, jinja-htmx, htmx-no-jinja, angular, and angular-cli.
HMR & Production Build
- Dev Mode (Single-Port Proxy): Vite runs on
runtime.portand writespaths.hot_file; Litestar proxies asset HTTP and the HMR WebSocket (/static/vite-hmr) so the browser uses a single public origin. In Vite 8.1+, place explicit HMR network overrides underserver.ws(notserver.hmr). See HMR Reference. - Production Build: Run
litestar assets build(orlitestar assets deploy) withdev_mode=False. Asset loading checks<bundle_dir>/<manifest_name>then<bundle_dir>/.vite/<manifest_name>. See Deployment Reference.
Inertia & HTMX Integration
- Inertia (`mode="hybrid"`): Configure
ViteConfig(mode="hybrid", inertia=InertiaConfig(...))on a singleVitePlugin. Returnmsgspec.Struct(..., rename="camel")prop bags from@get(..., component="...")handlers (field renames are preserved at top level). Stageshare(),flash(),error(), andclear_history()inInertiaTransientState, wirecsrfHeaders()intocreateInertiaApp({ defaults: { visitOptions } }), read flash messages from top-levelusePage().flash, and pass uninvoked callables todefer/lazy/optional/once. See Inertia Reference, Deferred & Merge Props, and Advanced Inertia Patterns. - HTMX (`mode="template"`): Pair
ViteConfig(mode="template")withTemplateConfigandHTMXPlugin().
<workflow>
Workflow
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/litestar-vite/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/litestar-org/litestar-skills/litestar-vite)