Deploying Vite apps anywhere.
POC that solves the issue point 1 and 3 of Netlify's RFC, i.e. "Server entry point location" and "Routing metadata". Mostly, how can a deployment target (Netlify, Cloudflare, Node, etc.) find and use the different server entries defined by a framework (or user)?
This POC demonstrates that we can solve this issue with a minimal API.
- Global Store: Register server entries (
@universal-deploy/store) - Universal Routing: Via the
URLPatternstandard - Minimal conventions: Can easily be adopted by any Vite-based framework
@universal-deploy/store provides a global registry for server entries with routing:
import { store } from "@universal-deploy/store";
store.entries.push({
id: "./src/server/api.ts",
pattern: "/api/*",
method: "GET",
});See the store documentation for full API details.
The following Vite plugins help frameworks and deployment providers work with the global entries store.
compat: Auto-registers SSR rollup entries in the store (for Vite-based frameworks that didn't adoptuniversal-deployyet).catchAll: Utility plugin that aggregates and routes all global store entries behind a unique entry. Used bydevServer,compatand node target.devServer: Can be used by a framework during development to route requests to the entries defined in the global store.
Temporary packages that demonstrate how deployment plugins can integrate @universal-deploy/store.
Packages like @universal-deploy/netlify will no longer be required once directly supported by Vite deployment plugins (e.g. @netlify/vite-plugin).
@universal-deploy/netlify@universal-deploy/node(Node.js, Bun, Deno)
Already compatible:
@cloudflare/vite-pluginvite-plugin-vercel@beta
Call store.entries.push at any point, preferably before configResolved hooks.
For deployment providers requiring a unique server entry, the easiest way is to set rollupOptions.input to catchAllEntry. This virtual entry will be resolved by the catchAll plugin.
For deployment providers with support for multiple server entries, read store.entries in a post configEnvironment hook and set rollupOptions.input.
Note
this.emitFile can also be used at later stages to achieve the same result.
examples/tanstack-start: TanStack Start app deployed to Netlify, Cloudflare, Vercel, or Node.js/Bun/Deno.- Minimal examples:
MIT