A server-side rendered React application built with TypeScript, Fastify, and Vite.
src/
├── client/ # Frontend React application
│ ├── App.tsx # Main React component
│ ├── App.css # Component styles
│ ├── index.css # Global styles
│ ├── index.html # HTML template
│ └── main.tsx # Client entry point
├── server/ # Backend server code
│ ├── controllers/ # API controllers
│ │ └── exampleController.ts
│ ├── routes.ts # API routes
│ └── ssr.ts # Server-side rendering logic
└── index.ts # Main server entry point
- ✅ React 18 with TypeScript
- ✅ Server-side rendering (SSR)
- ✅ Fastify backend with TypeScript
- ✅ Vite for fast development and building
- ✅ Client-side hydration
- ✅ API routes
- ✅ Hot reload during development
-
Install dependencies:
npm install
-
Development mode:
npm run dev
This will start both the build watcher and the development server.
-
Production build:
npm run build npm start
/react- Main React SSR application/api/data- Example API endpoint/api/example- Another example API endpoint/health- Health check endpoint
npm run dev- Start development mode with hot reloadnpm run build- Build for productionnpm run build:client- Build client-side assets onlynpm run build:server- Build server-side code onlynpm run serve- Start production servernpm start- Build and start production server
The app runs on http://localhost:3000 by default. The React application is available at http://localhost:3000/react.
During development, the client and server code are automatically rebuilt when files change. The server will restart automatically using nodemon.
PORT- Server port (default: 3000)NODE_ENV- Environment mode (development/production)