{"id":22850,"library":"vite-plugin-ssr","title":"vite-plugin-ssr","description":"A Vite plugin for server-side rendering (SSR) that follows the Unix philosophy of doing one thing well. Current stable version is 0.4.142. It provides a lightweight, framework-agnostic SSR solution for Vite, unlike full-featured meta-frameworks like Next.js or Nuxt. It supports file-based routing, data fetching, and hydration. The plugin is actively maintained with frequent releases. Key differentiators: it is a simple Vite plugin rather than a full framework, supports any frontend framework (React, Vue, Svelte, etc.), and integrates seamlessly with existing Vite setups. Requires Node >=16, Vite >=3.1.0, and react-streaming >=0.3.5 (for React).","status":"active","version":"0.4.142","language":"javascript","source_language":"en","source_url":"https://github.com/brillout/vite-plugin-ssr","tags":["javascript","vite","vite-plugin","ssr","typescript"],"install":[{"cmd":"npm install vite-plugin-ssr","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-ssr","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-ssr","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Enables streaming SSR for React apps","package":"react-streaming","optional":true},{"reason":"Peer dependency; plugin runs inside Vite's build pipeline","package":"vite","optional":false}],"imports":[{"note":"The main export is named, not default. Also, it's imported from 'vite-plugin-ssr/plugin' subpath, not the root.","wrong":"import vitePluginSsr from 'vite-plugin-ssr'","symbol":"vitePluginSsr","correct":"import { vitePluginSsr } from 'vite-plugin-ssr/plugin'"},{"note":"PageContext is a type and should be imported from the types subpath. Using value import will cause runtime errors.","wrong":"import { PageContext } from 'vite-plugin-ssr'","symbol":"PageContext","correct":"import type { PageContext } from 'vite-plugin-ssr/types'"},{"note":"Client-side hooks like usePageContext are exported from the client subpath, not the root.","wrong":"import { usePageContext } from 'vite-plugin-ssr'","symbol":"usePageContext","correct":"import { usePageContext } from 'vite-plugin-ssr/client'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite'\nimport { vitePluginSsr } from 'vite-plugin-ssr/plugin'\nimport react from '@vitejs/plugin-react'\n\nexport default defineConfig({\n  plugins: [react(), vitePluginSsr()]\n})\n\n// pages/index.page.tsx\nimport { usePageContext } from 'vite-plugin-ssr/client'\n\nexport default function Page() {\n  const { urlParsed } = usePageContext()\n  return <h1>Hello {urlParsed.pathname}</h1>\n}\n\n// renderer/_default.page.server.tsx\nimport { renderToString } from 'react-dom/server'\nimport { PageContext } from 'vite-plugin-ssr/types'\nimport { PageWrapper } from './PageWrapper'\n\nexport async function render(pageContext: PageContext) {\n  const pageHtml = renderToString(\n    <PageWrapper pageContext={pageContext} />\n  )\n  return { pageHtml }\n}","lang":"typescript","description":"Basic SSR setup with React: plugin configuration, a page component, and a server-side render function."},"warnings":[{"fix":"Update imports: use import { vitePluginSsr } from 'vite-plugin-ssr/plugin' instead of 'vite-plugin-ssr'","message":"In v0.4, the import path changed from 'vite-plugin-ssr' to subpaths like 'vite-plugin-ssr/plugin', 'vite-plugin-ssr/client', etc.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Import PageContext from 'vite-plugin-ssr/types' instead of 'vite-plugin-ssr'","message":"PageContext type import changed from 'vite-plugin-ssr' to 'vite-plugin-ssr/types'","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Use async function render(pageContext) with explicit return of { pageHtml } or similar","message":"The old `render` function signature (pageContext, renderPage) is deprecated; use the new context-based API.","severity":"deprecated","affected_versions":">=0.4.0"},{"fix":"Update Vite to >=3.1.0 and Node to >=16","message":"The plugin requires Vite >=3.1.0 and Node >=16. Using older versions will cause build failures.","severity":"gotcha","affected_versions":"all"},{"fix":"Run npm install react-streaming","message":"Client-side code that uses react-streaming must ensure the package is installed as a dependency (not just peer dep).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install latest version and use import { vitePluginSsr } from 'vite-plugin-ssr/plugin'","cause":"Import path is incorrect; the module is not at the root.","error":"Cannot find module 'vite-plugin-ssr/plugin'"},{"fix":"Use import { vitePluginSsr } from 'vite-plugin-ssr/plugin' (curly braces)","cause":"Default import instead of named import from the plugin subpath.","error":"TypeError: (0 , vitePluginSsr) is not a function"},{"fix":"Import PageContext from 'vite-plugin-ssr/types' and ensure version >=0.4.0","cause":"Using an older type definition or incorrect import path for PageContext.","error":"Property 'pageContext' does not exist on type 'PageContext'"},{"fix":"Upgrade Vite to >=3.1.0","cause":"Vite version is too old.","error":"The 'vite-plugin-ssr' plugin requires Vite 3.1 or newer."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}