This is a demo project showcasing React Router's capabilities in a full-stack application. It demonstrates how to create frontend routes, handle AJAX requests that connect directly to a database, and implement Server-Sent Events (SSE) for real-time streaming.
- 🚀 Full-stack application with unified codebase
- ⚡️ End-to-end type safety
- 🔄 Direct database access from routes
- 📶 Real-time streaming with Server-Sent Events (SSE)
- 🔒 TypeScript by default
- 🎯 Modern React with React Router v7
- 📖 React Router docs
app/routes.ts- Central routing configurationapp/root.tsx- Root component and main layout setupapp/layout.tsx- Shared UI layout componentsapp/routes/- Individual route componentsusers/- Example route with database integrationstream.tsx- Demo of Server-Sent Events (SSE)
app/models/- Server-side data logic (files end with.server.ts)app/db/- Database configuration and schemaschema.ts- Database schema definition- Drizzle ORM instance
- Users API:
GET /users- Example of database integration - Streaming Demo:
/stream- Real-time updates with Server-Sent Events
Install the dependencies:
npm installStart the development server with HMR:
npm run devYour application will be available at http://localhost:5173.
Create a production build:
npm run buildThis repo includes Playwright for E2E tests that exercise real route logic (loaders/actions, DB, SSR).
- Install Playwright and browsers:
npm install
npx playwright install- Run tests (builds app and serves on port 3000):
npm run test:e2e- Open the Playwright UI:
npm run test:e2e:uiNotes:
- Tests run the built server via
npm run start:ciand isolate the database usingDATABASE_URL=./pgdata-e2e. - Example specs live in
e2e/and cover the home page and basic Users CRUD.