Skip to content

maxh1t/react-ssr-template

Repository files navigation

React SSR Template

The production-ready template for building server-side rendered (SSR) React applications with Vite.

This repository complements the article: Building Production-Ready SSR React Applications

Adding Packages

Client

Add React or client-side libraries as regular dependencies:

npm install react

Server

Add server-side packages (e.g., express) as devDependencies:

npm install express --save-dev

Then, include the package in the server build by updating the tsup.config.ts:

import { defineConfig } from 'tsup'

export default defineConfig({
  entry: ['server'],
  outDir: 'dist/server',
  target: 'node22',
  format: ['cjs'],
  clean: true,
  minify: true,
  external: ['lightningcss', 'esbuild', 'vite'],
  noExternal: ['express', 'sirv', 'compression'], // Include server packages here
})