Vite isn't just for apps. Build a publishable library with the right output formats and types, and understand the multi-environment build model behind SSR.
Pick which output formats your package ships, then see the config and the resulting dist/.
One vite build can produce coordinated output for multiple runtimes. Each environment has its own module graph and config.
// Environment API (Vite 6+, stabilizing) — a sketch export default defineConfig({ environments: { client: { /* browser build */ }, ssr: { resolve: { external: ["express"] }, // rendered via the Module Runner at runtime }, }, }); // dev SSR: load your server entry through Vite's transform pipeline const { render } = await server.ssrLoadModule("/src/entry-server.tsx"); const html = await render(url);