FSX is a development project that implements Server-Side Rendering (SSR) for React applications using Express.js. The main goal is to create a lightweight alternative to Next.js with a focus on SEO optimization. Soon be ready to see more features and especially FSX-COMPILER and React-FSX (The FRAMEWORK)
Main Components:
server.js- Entry point, starts Express serverconfig/app.js- Express configuration with security middlewareroutes/ssr.js- Handles all client-side routes with SSRutils/renderer.js- Renders React components to HTMLutils/redis.js- Redis connection and caching utilities
Key Features:
- Express.js server with SSR rendering
- Redis caching for pages and images
- Security headers with Helmet.js
- Compression middleware
- Error handling middleware
Main Components:
App.tsx- Main React application with routingentry-client.tsx- The client entry that will be used at the client's build stepentry-server.tsx- The server entry file that willbe used in the server's build step.components/- Reusable React componentspages/- Page components for different routeshooks/- Custom React hookscontext/- React context providers
Key Features:
- React 19 with TypeScript/JavaScript
- React Router for client-side routing
- Tailwind CSS for styling
- Schema.org structured data
-
Request Flow:
Browser Request → Express Server → Check Redis Cache ↓ Cache Hit: Return cached HTML Cache Miss: Stream the React App to the client (A close to < 100ms step)→ Return HTML → Cache -
Rendering Process:
- Express server receives request
- Checks Redis cache for existing HTML
- If not cached, renders React app with
renderToPipeableStream(Stream means all data will be sent on-the-fly to the client, that will improve TimeToFirstByte) - Generates complete HTML with meta tags using the js files from the build process
- Caches the result in Redis
- Returns HTML to browser
-
Client Hydration:
- Browser receives HTML
- React app hydrates on the client
- Continues as SPA for navigation
- Key Format:
SSR:${url} - TTL: 7 days (604800 seconds)
- Content: Full HTML with meta tags
- Key Format:
IMG:${url} - TTL: 24 hours (86400 seconds)
- Content: Base64 encoded images
- Dynamic meta tags per page
- Open Graph and Twitter Cards
- Structured data with Schema.org
- Automatic sitemap and robots.txt
- Core Web Vitals monitoring
- Page load timing
- User interaction tracking
- Google Analytics integration
- Downloads images from URLs
- Converts to WebP format
- Optimizes file size
- Generates mapping for React components
- Generates project structure documentation
- Counts lines of code
- Creates markdown documentation
- Analyzes file types and sizes
- Start Redis server
- Run
pnpm run dev - Access application at
http://localhost:3000 - Server restart for server changes
- Run
pnpm run build:clientto build React app - Run
pnpm run deployto build and start production server - Use PM2 for process management
PORT- Server port (default: 3000)REDIS_URL- Redis connection stringNODE_ENV- Environment mode
Page meta data is configured in src/server/utils/renderer.js:
const pageMetaData = {
'/': {
title: 'Home - Your App',
description: 'Home page description',
url: 'https://yourdomain.com'
} // Read the examples of usage in the code to understand this part
};- XSS protection
- Clickjacking prevention
- MIME type sniffing protection
- Content Security Policy (CSP)
- URL validation for SSR routes
- Request size limits
- Error handling with graceful fallbacks
- Redis caching for pages and images
- Compression with gzip/brotli
- Static asset optimization
- Error handling middleware
- Code splitting with React Lazy and Vite SSR
- Lazy loading of components
- Image optimization with WebP
- Performance monitoring (In next commits)
docker-compose up -ddocker build -t fsx-app .
docker run -p 3000:3000 fsx-app- Redis Connection Errors - Check Redis server status and your in-app / env configs
- SSR Rendering Issues - Check React component and console for errors
- Build Errors - Verify Vite configuration
- Performance Issues - Monitor Redis cache hit rates
- Image optimization API
- Plugin system
- CLI tool for project initialization
- New React Compilation Engine
- Edge caching
- CDN integration
- Bundle size optimization
- Advanced monitoring
This is a development project for learning purposes. Contributions are welcome for:
- Bug fixes
- Performance improvements
- Documentation updates
- Feature enhancements
- This is a development version, not a production NPM package
- Designed for learning and practicing web development concepts, while reducing MY dependance on AI code generation tools
- Built by a 14-year-old Haitian developer