vite
Build and serve the browser side of your app with Vite, wired to kitrrc.ts by one plugin.
Developer toolsServerBuilt onvite
Every export of kitr/vite, kitr/vite/client, read from the published type definitions. The guide shows them in use.
kitr/vite
kitr
function kitr(options?: KitrPluginOptions): PluginOption[];
The kitr() Vite plugin. It reads kitrrc.ts and the installed packages' vite declarations
at build time and:
- wires TanStack Start (or the router plugin) and every plugin a package declares (React, Tailwind),
- exposes
virtual:kitr/providersandvirtual:kitr/configas static imports, - pre-declares
optimizeDepsfrom the packages' lists so dev start never rediscovers, - sets the active platform's port, outDir and the
#app-style aliases.
readPrerender
function readPrerender(root: string, configDir: string): {
pages?: Array<{
path: string;
}>;
prerender?: Record<string, unknown>;
sitemap?: Record<string, unknown>;
};
Static read of config/seo.ts: prerender: ['/a'] or { routes: [...], crawlLinks } becomes
Start's pages + prerender, and site.url turns on the sitemap. No execution needed.
readRc
function readRc(root: string): RcInfo;
Static read of kitrrc.ts: import('...') specs under providers: and the packages list. No execution needed.
readRcPlatforms
function readRcPlatforms(src: string): Record<string, RcPlatform>;
Static read of platforms: { site: web({ mode: 'ssr' }) }: names, factories and literal options.
KitrPluginOptions
interface KitrPluginOptions {
/** Project root. Default: Vite's root. */
root?: string;
/** Use TanStack Start (SSR, prerender, server functions). Default: when an installed package asks for it (`router` does). */
start?: boolean | Record<string, unknown>;
/**
* Leave out the Vite plugin a package declares, by its short name: `{ tailwind: false }` skips
* `@kitr/tailwind/vite`, `{ react: false }` skips `@vitejs/plugin-react`. Default: every declared plugin.
*/
plugins?: Record<string, boolean>;
/** Route files directory. Default `app/routes`. */
routesDirectory?: string;
generatedRouteTree?: string;
/** Extra options for @tanstack/router-plugin. */
router?: Record<string, unknown>;
/** Include `@kitr/devtools/provider`. Default: never in production builds, always otherwise. */
devtools?: boolean;
/** Which platform from kitrrc.ts this build is for. Default: `KITR_PLATFORM` (set by `kitr dev|build <name>`), else the first web platform. */
platform?: string;
/**
* Run `kitr types` when the build starts and again in dev whenever a watched file changes, so
* `.kitr/` is always current. Needs `@kitr/cli` installed (it is, in every kitr project).
* Default true.
*/
types?: boolean;
}