litestar-vite 0.1.1__py3-none-any.whl → 0.15.0rc2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. litestar_vite/__init__.py +54 -4
  2. litestar_vite/__metadata__.py +12 -7
  3. litestar_vite/_codegen/__init__.py +26 -0
  4. litestar_vite/_codegen/inertia.py +407 -0
  5. litestar_vite/_codegen/openapi.py +233 -0
  6. litestar_vite/_codegen/routes.py +653 -0
  7. litestar_vite/_codegen/ts.py +235 -0
  8. litestar_vite/_handler/__init__.py +8 -0
  9. litestar_vite/_handler/app.py +524 -0
  10. litestar_vite/_handler/routing.py +130 -0
  11. litestar_vite/cli.py +1147 -10
  12. litestar_vite/codegen.py +39 -0
  13. litestar_vite/commands.py +79 -0
  14. litestar_vite/config.py +1594 -70
  15. litestar_vite/deploy.py +355 -0
  16. litestar_vite/doctor.py +1179 -0
  17. litestar_vite/exceptions.py +78 -0
  18. litestar_vite/executor.py +316 -0
  19. litestar_vite/handler.py +9 -0
  20. litestar_vite/html_transform.py +426 -0
  21. litestar_vite/inertia/__init__.py +53 -0
  22. litestar_vite/inertia/_utils.py +114 -0
  23. litestar_vite/inertia/exception_handler.py +172 -0
  24. litestar_vite/inertia/helpers.py +1043 -0
  25. litestar_vite/inertia/middleware.py +54 -0
  26. litestar_vite/inertia/plugin.py +133 -0
  27. litestar_vite/inertia/request.py +286 -0
  28. litestar_vite/inertia/response.py +706 -0
  29. litestar_vite/inertia/types.py +316 -0
  30. litestar_vite/loader.py +462 -121
  31. litestar_vite/plugin.py +2160 -21
  32. litestar_vite/py.typed +0 -0
  33. litestar_vite/scaffolding/__init__.py +20 -0
  34. litestar_vite/scaffolding/generator.py +270 -0
  35. litestar_vite/scaffolding/templates.py +437 -0
  36. litestar_vite/templates/__init__.py +0 -0
  37. litestar_vite/templates/addons/tailwindcss/tailwind.css.j2 +1 -0
  38. litestar_vite/templates/angular/index.html.j2 +12 -0
  39. litestar_vite/templates/angular/openapi-ts.config.ts.j2 +18 -0
  40. litestar_vite/templates/angular/package.json.j2 +35 -0
  41. litestar_vite/templates/angular/src/app/app.component.css.j2 +3 -0
  42. litestar_vite/templates/angular/src/app/app.component.html.j2 +1 -0
  43. litestar_vite/templates/angular/src/app/app.component.ts.j2 +9 -0
  44. litestar_vite/templates/angular/src/app/app.config.ts.j2 +5 -0
  45. litestar_vite/templates/angular/src/main.ts.j2 +9 -0
  46. litestar_vite/templates/angular/src/styles.css.j2 +9 -0
  47. litestar_vite/templates/angular/tsconfig.app.json.j2 +34 -0
  48. litestar_vite/templates/angular/tsconfig.json.j2 +20 -0
  49. litestar_vite/templates/angular/vite.config.ts.j2 +21 -0
  50. litestar_vite/templates/angular-cli/.postcssrc.json.j2 +5 -0
  51. litestar_vite/templates/angular-cli/angular.json.j2 +36 -0
  52. litestar_vite/templates/angular-cli/openapi-ts.config.ts.j2 +18 -0
  53. litestar_vite/templates/angular-cli/package.json.j2 +27 -0
  54. litestar_vite/templates/angular-cli/proxy.conf.json.j2 +18 -0
  55. litestar_vite/templates/angular-cli/src/app/app.component.css.j2 +3 -0
  56. litestar_vite/templates/angular-cli/src/app/app.component.html.j2 +1 -0
  57. litestar_vite/templates/angular-cli/src/app/app.component.ts.j2 +9 -0
  58. litestar_vite/templates/angular-cli/src/app/app.config.ts.j2 +5 -0
  59. litestar_vite/templates/angular-cli/src/index.html.j2 +13 -0
  60. litestar_vite/templates/angular-cli/src/main.ts.j2 +6 -0
  61. litestar_vite/templates/angular-cli/src/styles.css.j2 +10 -0
  62. litestar_vite/templates/angular-cli/tailwind.config.js.j2 +4 -0
  63. litestar_vite/templates/angular-cli/tsconfig.app.json.j2 +16 -0
  64. litestar_vite/templates/angular-cli/tsconfig.json.j2 +26 -0
  65. litestar_vite/templates/angular-cli/tsconfig.spec.json.j2 +9 -0
  66. litestar_vite/templates/astro/astro.config.mjs.j2 +28 -0
  67. litestar_vite/templates/astro/openapi-ts.config.ts.j2 +15 -0
  68. litestar_vite/templates/astro/src/layouts/Layout.astro.j2 +63 -0
  69. litestar_vite/templates/astro/src/pages/index.astro.j2 +36 -0
  70. litestar_vite/templates/astro/src/styles/global.css.j2 +1 -0
  71. litestar_vite/templates/base/.gitignore.j2 +42 -0
  72. litestar_vite/templates/base/openapi-ts.config.ts.j2 +15 -0
  73. litestar_vite/templates/base/package.json.j2 +38 -0
  74. litestar_vite/templates/base/resources/vite-env.d.ts.j2 +1 -0
  75. litestar_vite/templates/base/tsconfig.json.j2 +37 -0
  76. litestar_vite/templates/htmx/src/main.js.j2 +8 -0
  77. litestar_vite/templates/htmx/templates/base.html.j2.j2 +56 -0
  78. litestar_vite/templates/htmx/templates/index.html.j2.j2 +13 -0
  79. litestar_vite/templates/htmx/vite.config.ts.j2 +40 -0
  80. litestar_vite/templates/nuxt/app.vue.j2 +29 -0
  81. litestar_vite/templates/nuxt/composables/useApi.ts.j2 +33 -0
  82. litestar_vite/templates/nuxt/nuxt.config.ts.j2 +31 -0
  83. litestar_vite/templates/nuxt/openapi-ts.config.ts.j2 +15 -0
  84. litestar_vite/templates/nuxt/pages/index.vue.j2 +54 -0
  85. litestar_vite/templates/react/index.html.j2 +13 -0
  86. litestar_vite/templates/react/src/App.css.j2 +56 -0
  87. litestar_vite/templates/react/src/App.tsx.j2 +19 -0
  88. litestar_vite/templates/react/src/main.tsx.j2 +10 -0
  89. litestar_vite/templates/react/vite.config.ts.j2 +39 -0
  90. litestar_vite/templates/react-inertia/index.html.j2 +14 -0
  91. litestar_vite/templates/react-inertia/package.json.j2 +46 -0
  92. litestar_vite/templates/react-inertia/resources/App.css.j2 +68 -0
  93. litestar_vite/templates/react-inertia/resources/main.tsx.j2 +17 -0
  94. litestar_vite/templates/react-inertia/resources/pages/Home.tsx.j2 +18 -0
  95. litestar_vite/templates/react-inertia/resources/ssr.tsx.j2 +19 -0
  96. litestar_vite/templates/react-inertia/vite.config.ts.j2 +59 -0
  97. litestar_vite/templates/react-router/index.html.j2 +12 -0
  98. litestar_vite/templates/react-router/src/App.css.j2 +17 -0
  99. litestar_vite/templates/react-router/src/App.tsx.j2 +7 -0
  100. litestar_vite/templates/react-router/src/main.tsx.j2 +10 -0
  101. litestar_vite/templates/react-router/vite.config.ts.j2 +39 -0
  102. litestar_vite/templates/react-tanstack/index.html.j2 +12 -0
  103. litestar_vite/templates/react-tanstack/openapi-ts.config.ts.j2 +18 -0
  104. litestar_vite/templates/react-tanstack/src/App.css.j2 +17 -0
  105. litestar_vite/templates/react-tanstack/src/main.tsx.j2 +21 -0
  106. litestar_vite/templates/react-tanstack/src/routeTree.gen.ts.j2 +7 -0
  107. litestar_vite/templates/react-tanstack/src/routes/__root.tsx.j2 +9 -0
  108. litestar_vite/templates/react-tanstack/src/routes/books.tsx.j2 +9 -0
  109. litestar_vite/templates/react-tanstack/src/routes/index.tsx.j2 +9 -0
  110. litestar_vite/templates/react-tanstack/vite.config.ts.j2 +39 -0
  111. litestar_vite/templates/svelte/index.html.j2 +13 -0
  112. litestar_vite/templates/svelte/src/App.svelte.j2 +30 -0
  113. litestar_vite/templates/svelte/src/app.css.j2 +45 -0
  114. litestar_vite/templates/svelte/src/main.ts.j2 +8 -0
  115. litestar_vite/templates/svelte/src/vite-env.d.ts.j2 +2 -0
  116. litestar_vite/templates/svelte/svelte.config.js.j2 +5 -0
  117. litestar_vite/templates/svelte/vite.config.ts.j2 +39 -0
  118. litestar_vite/templates/svelte-inertia/index.html.j2 +14 -0
  119. litestar_vite/templates/svelte-inertia/resources/app.css.j2 +21 -0
  120. litestar_vite/templates/svelte-inertia/resources/main.ts.j2 +11 -0
  121. litestar_vite/templates/svelte-inertia/resources/pages/Home.svelte.j2 +43 -0
  122. litestar_vite/templates/svelte-inertia/resources/vite-env.d.ts.j2 +2 -0
  123. litestar_vite/templates/svelte-inertia/svelte.config.js.j2 +5 -0
  124. litestar_vite/templates/svelte-inertia/vite.config.ts.j2 +37 -0
  125. litestar_vite/templates/sveltekit/openapi-ts.config.ts.j2 +15 -0
  126. litestar_vite/templates/sveltekit/src/app.css.j2 +40 -0
  127. litestar_vite/templates/sveltekit/src/app.html.j2 +12 -0
  128. litestar_vite/templates/sveltekit/src/hooks.server.ts.j2 +55 -0
  129. litestar_vite/templates/sveltekit/src/routes/+layout.svelte.j2 +12 -0
  130. litestar_vite/templates/sveltekit/src/routes/+page.svelte.j2 +34 -0
  131. litestar_vite/templates/sveltekit/svelte.config.js.j2 +12 -0
  132. litestar_vite/templates/sveltekit/tsconfig.json.j2 +14 -0
  133. litestar_vite/templates/sveltekit/vite.config.ts.j2 +31 -0
  134. litestar_vite/templates/vue/env.d.ts.j2 +7 -0
  135. litestar_vite/templates/vue/index.html.j2 +13 -0
  136. litestar_vite/templates/vue/src/App.vue.j2 +28 -0
  137. litestar_vite/templates/vue/src/main.ts.j2 +5 -0
  138. litestar_vite/templates/vue/src/style.css.j2 +45 -0
  139. litestar_vite/templates/vue/vite.config.ts.j2 +39 -0
  140. litestar_vite/templates/vue-inertia/env.d.ts.j2 +7 -0
  141. litestar_vite/templates/vue-inertia/index.html.j2 +14 -0
  142. litestar_vite/templates/vue-inertia/package.json.j2 +49 -0
  143. litestar_vite/templates/vue-inertia/resources/main.ts.j2 +18 -0
  144. litestar_vite/templates/vue-inertia/resources/pages/Home.vue.j2 +22 -0
  145. litestar_vite/templates/vue-inertia/resources/ssr.ts.j2 +21 -0
  146. litestar_vite/templates/vue-inertia/resources/style.css.j2 +21 -0
  147. litestar_vite/templates/vue-inertia/vite.config.ts.j2 +59 -0
  148. litestar_vite-0.15.0rc2.dist-info/METADATA +230 -0
  149. litestar_vite-0.15.0rc2.dist-info/RECORD +151 -0
  150. {litestar_vite-0.1.1.dist-info → litestar_vite-0.15.0rc2.dist-info}/WHEEL +1 -1
  151. litestar_vite/template_engine.py +0 -103
  152. litestar_vite-0.1.1.dist-info/METADATA +0 -68
  153. litestar_vite-0.1.1.dist-info/RECORD +0 -11
  154. {litestar_vite-0.1.1.dist-info → litestar_vite-0.15.0rc2.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,45 @@
1
+ :root {
2
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ line-height: 1.5;
4
+ font-weight: 400;
5
+
6
+ color-scheme: light dark;
7
+ color: rgba(255, 255, 255, 0.87);
8
+ background-color: #242424;
9
+
10
+ font-synthesis: none;
11
+ text-rendering: optimizeLegibility;
12
+ -webkit-font-smoothing: antialiased;
13
+ -moz-osx-font-smoothing: grayscale;
14
+ }
15
+
16
+ button {
17
+ border-radius: 8px;
18
+ border: 1px solid transparent;
19
+ padding: 0.6em 1.2em;
20
+ font-size: 1em;
21
+ font-weight: 500;
22
+ font-family: inherit;
23
+ background-color: #1a1a1a;
24
+ cursor: pointer;
25
+ transition: border-color 0.25s;
26
+ }
27
+
28
+ button:hover {
29
+ border-color: #646cff;
30
+ }
31
+
32
+ button:focus,
33
+ button:focus-visible {
34
+ outline: 4px auto -webkit-focus-ring-color;
35
+ }
36
+
37
+ @media (prefers-color-scheme: light) {
38
+ :root {
39
+ color: #213547;
40
+ background-color: #ffffff;
41
+ }
42
+ button {
43
+ background-color: #f9f9f9;
44
+ }
45
+ }
@@ -0,0 +1,39 @@
1
+ import { defineConfig } from "vite";
2
+ import vue from "@vitejs/plugin-vue";
3
+ import litestar from "litestar-vite-plugin";
4
+ {% if use_tailwind %}
5
+ import tailwindcss from "@tailwindcss/vite";
6
+ {% endif %}
7
+
8
+ export default defineConfig({
9
+ server: {
10
+ host: "0.0.0.0",
11
+ port: Number(process.env.VITE_PORT || "{{ vite_port }}"),
12
+ cors: true,
13
+ hmr: {
14
+ host: "localhost",
15
+ },
16
+ },
17
+ plugins: [
18
+ {% if use_tailwind %}
19
+ tailwindcss(),
20
+ {% endif %}
21
+ vue(),
22
+ litestar({
23
+ input: ["{{ resource_dir }}/main.ts"],
24
+ {% if enable_types %}
25
+ types: {
26
+ enabled: true,
27
+ output: "{{ resource_dir }}/generated/types",
28
+ generateZod: true,
29
+ generateSdk: true,
30
+ },
31
+ {% endif %}
32
+ }),
33
+ ],
34
+ resolve: {
35
+ alias: {
36
+ "@": "/{{ resource_dir }}",
37
+ },
38
+ },
39
+ });
@@ -0,0 +1,7 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ declare module "*.vue" {
4
+ import type { DefineComponent } from "vue";
5
+ const component: DefineComponent<{}, {}, any>;
6
+ export default component;
7
+ }
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/static/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title inertia>{{ project_name }}</title>
8
+ {{ "{{ vite_hmr() }}" }}
9
+ {{ "{{ vite('{{ resource_dir }}/main.ts') }}" }}
10
+ </head>
11
+ <body>
12
+ <div id="app" data-page='{{ "{{ inertia | safe }}" }}'></div>
13
+ </body>
14
+ </html>
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "{{ project_name }}",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "vite",
7
+ {% if enable_ssr %}
8
+ "build": "vite build{% if use_typescript %} && vue-tsc -b --noEmit{% endif %} && vite build --ssr {{ resource_dir }}/ssr.ts",
9
+ {% else %}
10
+ "build": "vite build{% if use_typescript %} && vue-tsc -b --noEmit{% endif %}",
11
+ {% endif %}
12
+ "preview": "vite preview",
13
+ {% if enable_ssr %}
14
+ "serve": "NODE_ENV=production node {{ resource_dir }}/bootstrap/ssr/ssr.js",
15
+ {% else %}
16
+ "serve": "vite preview",
17
+ {% endif %}
18
+ "watch": "npm run serve"{% if generate_client %},
19
+ "generate-types": "openapi-ts"{% endif %}
20
+ },
21
+ "dependencies": {
22
+ {%- for dep in dependencies %}
23
+ "{{ dep }}": "latest"{% if not loop.last or generate_zod or generate_client or enable_ssr %},{% endif %}
24
+ {%- endfor %}
25
+ {%- if generate_client %}
26
+ "axios": "^1.13.2"{% if generate_zod or enable_ssr %},{% endif %}
27
+ {%- endif %}
28
+ {%- if generate_zod %}
29
+ "zod": "^4.1.13"{% if enable_ssr %},{% endif %}
30
+ {%- endif %}
31
+ {%- if enable_ssr %}
32
+ "@vue/server-renderer": "latest"
33
+ {%- endif %}
34
+ },
35
+ "devDependencies": {
36
+ {%- for dep in dev_dependencies %}
37
+ "{{ dep }}": "latest",
38
+ {%- endfor %}
39
+ {%- if use_tailwind %}
40
+ "@tailwindcss/vite": "^4.1.17",
41
+ "tailwindcss": "^4.1.17",
42
+ {%- endif %}
43
+ {%- if generate_client %}
44
+ "@hey-api/openapi-ts": "^0.88.0",
45
+ {%- endif %}
46
+ "litestar-vite-plugin": "latest",
47
+ "vite": "^7.2.6"
48
+ }
49
+ }
@@ -0,0 +1,18 @@
1
+ import { createInertiaApp } from "@inertiajs/vue3";
2
+ import { resolvePageComponent } from "litestar-vite-plugin/inertia-helpers";
3
+ import type { DefineComponent } from "vue";
4
+ import { createApp, h } from "vue";
5
+ import "./style.css";
6
+
7
+ createInertiaApp({
8
+ resolve: (name) =>
9
+ resolvePageComponent(
10
+ `./pages/${name}.vue`,
11
+ import.meta.glob<DefineComponent>("./pages/**/*.vue"),
12
+ ),
13
+ setup({ el, App, props, plugin }) {
14
+ createApp({ render: () => h(App, props) })
15
+ .use(plugin)
16
+ .mount(el);
17
+ },
18
+ });
@@ -0,0 +1,22 @@
1
+ <script setup lang="ts">
2
+ import { Head, Link } from "@inertiajs/vue3";
3
+
4
+ defineProps<{
5
+ message?: string;
6
+ }>();
7
+ </script>
8
+
9
+ <template>
10
+ <Head title="Home" />
11
+ <div class="max-w-5xl mx-auto px-4 py-10 text-center space-y-6">
12
+ <h1 class="text-3xl font-semibold text-[#202235]">{{ "{{ project_name }}" }}</h1>
13
+ <p class="text-slate-600">Vue 3 + Inertia.js + Litestar</p>
14
+ <p v-if="message" class="text-[#646cff] font-medium">{{ "{{ message }}" }}</p>
15
+
16
+ <nav class="flex justify-center gap-4">
17
+ <Link href="/books" class="rounded-full bg-[#202235] px-6 py-2 font-semibold text-white text-sm transition hover:bg-[#2d3348]">
18
+ View Books
19
+ </Link>
20
+ </nav>
21
+ </div>
22
+ </template>
@@ -0,0 +1,21 @@
1
+ import { createInertiaApp } from "@inertiajs/vue3";
2
+ import createServer from "@inertiajs/vue3/server";
3
+ import { renderToString } from "@vue/server-renderer";
4
+ import { createSSRApp, h } from "vue";
5
+
6
+ import { resolvePageComponent } from "litestar-vite-plugin/inertia-helpers";
7
+
8
+ createServer(
9
+ (page) =>
10
+ createInertiaApp({
11
+ page,
12
+ render: renderToString,
13
+ resolve: (name) => resolvePageComponent(`./pages/${name}.vue`, import.meta.glob("./pages/**/*.vue")),
14
+ setup({ App, props, plugin }) {
15
+ return createSSRApp({
16
+ render: () => h(App, props),
17
+ }).use(plugin);
18
+ },
19
+ }),
20
+ Number.parseInt(process.env.INERTIA_SSR_PORT || "13714"),
21
+ );
@@ -0,0 +1,21 @@
1
+ :root {
2
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ line-height: 1.5;
4
+ font-weight: 400;
5
+
6
+ color-scheme: light dark;
7
+ color: rgba(255, 255, 255, 0.87);
8
+ background-color: #242424;
9
+
10
+ font-synthesis: none;
11
+ text-rendering: optimizeLegibility;
12
+ -webkit-font-smoothing: antialiased;
13
+ -moz-osx-font-smoothing: grayscale;
14
+ }
15
+
16
+ @media (prefers-color-scheme: light) {
17
+ :root {
18
+ color: #213547;
19
+ background-color: #ffffff;
20
+ }
21
+ }
@@ -0,0 +1,59 @@
1
+ import { defineConfig } from "vite";
2
+ import vue from "@vitejs/plugin-vue";
3
+ import litestar from "litestar-vite-plugin";
4
+ {% if use_tailwind %}
5
+ import tailwindcss from "@tailwindcss/vite";
6
+ {% endif %}
7
+
8
+ {% if enable_ssr %}
9
+ export default defineConfig(({ ssrBuild }) => ({
10
+ {% else %}
11
+ export default defineConfig({
12
+ {% endif %}
13
+ server: {
14
+ host: "0.0.0.0",
15
+ port: Number(process.env.VITE_PORT || "{{ vite_port }}"),
16
+ cors: true,
17
+ hmr: {
18
+ host: "localhost",
19
+ },
20
+ },
21
+ plugins: [
22
+ {% if use_tailwind %}
23
+ tailwindcss(),
24
+ {% endif %}
25
+ vue(),
26
+ litestar({
27
+ input: ["{{ resource_dir }}/main.ts"],
28
+ {% if enable_ssr %}
29
+ ssr: "{{ resource_dir }}/ssr.ts",
30
+ {% endif %}
31
+ {% if enable_types %}
32
+ types: {
33
+ enabled: true,
34
+ output: "{{ resource_dir }}/generated/api",
35
+ },
36
+ {% endif %}
37
+ }),
38
+ ],
39
+ {% if enable_ssr %}
40
+ build: {
41
+ rollupOptions: {
42
+ output: ssrBuild
43
+ ? {
44
+ entryFileNames: "ssr.js",
45
+ }
46
+ : undefined,
47
+ },
48
+ },
49
+ {% endif %}
50
+ resolve: {
51
+ alias: {
52
+ "@": "/{{ resource_dir }}",
53
+ },
54
+ },
55
+ {% if enable_ssr %}
56
+ }));
57
+ {% else %}
58
+ });
59
+ {% endif %}
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.4
2
+ Name: litestar-vite
3
+ Version: 0.15.0rc2
4
+ Summary: Vite plugin for Litestar
5
+ Project-URL: Changelog, https://litestar-org.github.io/litestar-vite/latest/changelog
6
+ Project-URL: Discord, https://discord.gg/X3FJqy8d2j
7
+ Project-URL: Documentation, https://litestar-org.github.io/litestar-vite/latest/
8
+ Project-URL: Homepage, https://litestar-org.github.io/litestar-vite/latest/
9
+ Project-URL: Issue, https://github.com/litestar-org/litestar-vite/issues/
10
+ Project-URL: Source, https://github.com/litestar-org/litestar-vite
11
+ Author-email: Cody Fincher <cody.fincher@gmail.com>
12
+ License: MIT
13
+ License-File: LICENSE
14
+ Keywords: litestar,vite
15
+ Classifier: Environment :: Web Environment
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Intended Audience :: System Administrators
18
+ Classifier: License :: OSI Approved :: MIT License
19
+ Classifier: Natural Language :: English
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Programming Language :: Python
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Programming Language :: Python :: 3.14
27
+ Classifier: Topic :: Database
28
+ Classifier: Topic :: Database :: Database Engines/Servers
29
+ Classifier: Topic :: Software Development
30
+ Classifier: Typing :: Typed
31
+ Requires-Python: >=3.10
32
+ Requires-Dist: httpx>=0.24.1
33
+ Requires-Dist: litestar>=2.7.0
34
+ Requires-Dist: typing-extensions
35
+ Requires-Dist: websockets>=12.0
36
+ Provides-Extra: http2
37
+ Requires-Dist: h2>=4.0.0; extra == 'http2'
38
+ Provides-Extra: jinja
39
+ Requires-Dist: jinja2; extra == 'jinja'
40
+ Provides-Extra: nodeenv
41
+ Requires-Dist: nodeenv; extra == 'nodeenv'
42
+ Description-Content-Type: text/markdown
43
+
44
+ # Litestar Vite
45
+
46
+ 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.
47
+
48
+ ## Features
49
+
50
+ - One-port dev: proxies Vite HTTP + WS/HMR through Litestar by default; switch to two-port with `VITE_PROXY_MODE=direct`.
51
+ - SSR framework support: use `proxy_mode="ssr"` for Astro, Nuxt, SvelteKit - proxies everything except your API routes.
52
+ - Production assets: reads Vite manifest from `public/manifest.json` (configurable) and serves under `asset_url`.
53
+ - Type-safe frontends: optional OpenAPI/routes export + `@hey-api/openapi-ts` via the Vite plugin.
54
+ - Inertia support: v2 protocol with session middleware and optional SPA mode.
55
+
56
+ ## Quick Start (SPA)
57
+
58
+ ```bash
59
+ pip install litestar-vite
60
+ ```
61
+
62
+ ```python
63
+ import os
64
+ from pathlib import Path
65
+ from litestar import Litestar
66
+ from litestar_vite import VitePlugin, ViteConfig, PathConfig
67
+
68
+ DEV_MODE = os.getenv("VITE_DEV_MODE", "true").lower() in ("true", "1", "yes")
69
+
70
+ app = Litestar(
71
+ plugins=[VitePlugin(config=ViteConfig(
72
+ dev_mode=DEV_MODE,
73
+ paths=PathConfig(root=Path(__file__).parent),
74
+ ))]
75
+ )
76
+ ```
77
+
78
+ ```bash
79
+ litestar run --reload # Vite dev server is proxied automatically
80
+ ```
81
+
82
+ Scaffold a frontend: `litestar assets init --template vue` (or `react`, `svelte`, `htmx`, `react-inertia`, `vue-inertia`, `angular`, `astro`, `nuxt`, `sveltekit`).
83
+
84
+ ## Development
85
+
86
+ To contribute or run the development project:
87
+
88
+ ```bash
89
+ # Install all dependencies and build packages
90
+ make install && make build
91
+
92
+ # Install frontend dependencies for an example
93
+ uv run litestar --app-dir examples/vue-inertia assets install
94
+
95
+ # Run the development server
96
+ uv run litestar --app-dir examples/vue-inertia run
97
+ ```
98
+
99
+ Replace `vue-inertia` with any other example: `vue`, `react`, `svelte`, `react-inertia`, `htmx`, `angular`, `astro`, `nuxt`, or `sveltekit`.
100
+
101
+ ## Template / HTMX
102
+
103
+ ```python
104
+ from pathlib import Path
105
+ from litestar import Litestar
106
+ from litestar.contrib.jinja import JinjaTemplateEngine
107
+ from litestar.template import TemplateConfig
108
+ from litestar_vite import VitePlugin, ViteConfig, PathConfig
109
+
110
+ here = Path(__file__).parent
111
+
112
+ app = Litestar(
113
+ template_config=TemplateConfig(directory=here / "templates", engine=JinjaTemplateEngine),
114
+ plugins=[VitePlugin(config=ViteConfig(
115
+ dev_mode=True,
116
+ paths=PathConfig(root=here),
117
+ ))],
118
+ )
119
+ ```
120
+
121
+ ## Inertia (v2)
122
+
123
+ Requires session middleware (32-char secret).
124
+
125
+ ```python
126
+ import os
127
+ from pathlib import Path
128
+ from litestar import Litestar
129
+ from litestar.middleware.session.client_side import CookieBackendConfig
130
+ from litestar_vite import VitePlugin, ViteConfig, PathConfig
131
+ from litestar_vite.inertia import InertiaConfig
132
+
133
+ here = Path(__file__).parent
134
+ SECRET_KEY = os.environ.get("SECRET_KEY", "development-only-secret-32-chars")
135
+ session = CookieBackendConfig(secret=SECRET_KEY.encode("utf-8"))
136
+
137
+ app = Litestar(
138
+ middleware=[session.middleware],
139
+ plugins=[VitePlugin(config=ViteConfig(
140
+ dev_mode=True,
141
+ paths=PathConfig(root=here),
142
+ inertia=InertiaConfig(root_template="index.html"),
143
+ ))],
144
+ )
145
+ ```
146
+
147
+ ## Meta-frameworks (Astro, Nuxt, SvelteKit)
148
+
149
+ Use `proxy_mode="ssr"` to proxy non-API routes to the framework's dev server:
150
+
151
+ ```python
152
+ import os
153
+ from pathlib import Path
154
+ from litestar import Litestar
155
+ from litestar_vite import VitePlugin, ViteConfig, PathConfig, RuntimeConfig
156
+
157
+ here = Path(__file__).parent
158
+ DEV_MODE = os.getenv("VITE_DEV_MODE", "true").lower() in ("true", "1", "yes")
159
+
160
+ app = Litestar(
161
+ plugins=[
162
+ VitePlugin(config=ViteConfig(
163
+ dev_mode=DEV_MODE,
164
+ paths=PathConfig(root=here),
165
+ runtime=RuntimeConfig(proxy_mode="ssr"),
166
+ ))
167
+ ],
168
+ )
169
+ ```
170
+
171
+ ### Proxy Modes
172
+
173
+ | Mode | Alias | Use Case |
174
+ |------|-------|----------|
175
+ | `vite` | - | SPAs - proxies Vite assets only (default) |
176
+ | `direct` | - | Two-port dev - expose Vite port directly |
177
+ | `proxy` | `ssr` | Meta-frameworks - proxies everything except API routes |
178
+
179
+ ### Production Deployment
180
+
181
+ **Astro (static):** Astro generates static HTML by default. Build and serve with Litestar:
182
+
183
+ ```bash
184
+ litestar --app-dir examples/astro assets install
185
+ litestar --app-dir examples/astro assets build
186
+ VITE_DEV_MODE=false litestar --app-dir examples/astro run
187
+ ```
188
+
189
+ **Nuxt/SvelteKit (SSR):** These run their own Node servers. Deploy as two services:
190
+
191
+ ```bash
192
+ # Terminal 1: SSR server
193
+ litestar --app-dir examples/nuxt assets build
194
+ litestar --app-dir examples/nuxt assets serve
195
+
196
+ # Terminal 2: Litestar API
197
+ VITE_DEV_MODE=false litestar --app-dir examples/nuxt run --port 8001
198
+ ```
199
+
200
+ ## Type generation
201
+
202
+ ```python
203
+ VitePlugin(config=ViteConfig(types=True)) # enable exports
204
+ ```
205
+
206
+ ```bash
207
+ litestar assets generate-types # one-off or CI
208
+ ```
209
+
210
+ ## CLI cheat sheet
211
+
212
+ - `litestar assets doctor` — diagnose/fix config
213
+ - `litestar assets init --template react|vue|svelte|...` — scaffold frontend
214
+ - `litestar assets build` / `serve` — build or watch
215
+ - `litestar assets deploy --storage gcs://bucket/assets` — upload via fsspec
216
+ - `litestar assets generate-types` — OpenAPI + routes → TS types
217
+ - `litestar assets install` — install frontend deps with the configured executor
218
+
219
+ ### Doctor command highlights
220
+
221
+ - Prints Python vs Vite config snapshot (asset URLs, bundle/hot paths, ports, modes).
222
+ - Flags missing hot file (dev proxy), missing manifest (prod), type-gen exports, env/config mismatches, and plugin install issues.
223
+ - `--fix` can rewrite simple vite.config values (assetUrl, bundleDir, hotFile, type paths) after creating a backup.
224
+
225
+ ## Links
226
+
227
+ - Docs: <https://litestar-org.github.io/litestar-vite/>
228
+ - Examples: `examples/` (react, vue, svelte, react-inertia, vue-inertia, astro, nuxt, sveltekit, htmx)
229
+ - Real-world example: [litestar-fullstack](https://github.com/litestar-org/litestar-fullstack) - Full-featured application using litestar-vite
230
+ - Issues: <https://github.com/litestar-org/litestar-vite/issues/>