π A complete Nuxt.js hybrid rendering example project showcasing the practical applications and best practices of SSG, ISR, and SSR rendering modes.
- π― Three Rendering Mode Demos: Complete examples of SSG, ISR, and SSR
- π¨ Modern UI Design: Beautiful interface based on Nuxt's official green theme
- π± Responsive Design: Perfect adaptation for desktop and mobile
- β‘ Performance Optimization: Performance optimization strategies for different rendering modes
- π§ TypeScript Support: Complete type-safe development experience
- π Real-time Data Display: Dynamic data and real-time updates on SSR pages
- π Incremental Updates: Smart caching and on-demand updates for ISR pages
βββ app/
β βββ app.vue # Application entry point
βββ assets/
β βββ css/
β βββ main.css # Main stylesheet (Nuxt green theme)
βββ layouts/
β βββ default.vue # Default layout
βββ pages/
β βββ index.vue # Home page (SSG)
β βββ ssg.vue # SSG example page
β βββ isr.vue # ISR example page
β βββ ssr.vue # SSR example page
βββ server/
β βββ api/
β βββ ssr-data.ts # SSR dynamic data API
β βββ isr-content.ts # ISR content API
βββ nuxt.config.ts # Nuxt configuration (hybrid rendering rules)
βββ package.json
| Feature | SSG | ISR | SSR |
|---|---|---|---|
| First Load | β‘ Extremely Fast (<100ms) | π Fast (~120ms) | π Medium (~300ms) |
| Content Freshness | π Requires Rebuild | β Auto Update | β Real-time |
| Server Load | β None | π Low | π High |
| SEO Friendly | β Perfect | β Perfect | β Good |
| Use Cases | Docs, Corporate | Blog, E-commerce | Dashboard, Social |
- Node.js 18+
- npm / yarn / pnpm
# Using npm
npm install
# Using yarn
yarn install
# Using pnpm
pnpm installStart the development server at http://localhost:3000:
# Using npm
npm run dev
# Using yarn
yarn dev
# Using pnpm
pnpm dev# Build application
npm run build
# Generate static site
npm run generate
# Preview production build
npm run preview- Rendering Mode: SSG (Static Site Generation)
- Features: Generated at build time, fastest loading speed
- Content: Project introduction, tech stack showcase, quick start guide
- Rendering Mode: SSG (Static Site Generation)
- Features: Demonstrates SSG principles, performance advantages and configuration methods
- Content: Technical principles, performance comparison, use cases, code examples
- Rendering Mode: ISR (Incremental Static Regeneration)
- Features: Combines advantages of static generation and dynamic updates
- Content: Real-time content display, working principles, configuration examples, advantage comparison
- Rendering Mode: SSR (Server-Side Rendering)
- Features: Real-time data, dynamic content, personalized experience
- Content: Real-time dashboard, user activity, system status, API call demonstrations
export default defineNuxtConfig({
// CSS Configuration
css: ['~/assets/css/main.css'],
// Hybrid Rendering Route Rules
routeRules: {
'/': { prerender: true }, // SSG - Home
'/ssg': { prerender: true }, // SSG - Static Generation
'/isr': { isr: true }, // ISR - Incremental Static Regeneration
'/ssr': { ssr: true } // SSR - Server-Side Rendering
},
// TypeScript Configuration
typescript: {
strict: true,
typeCheck: true
}
})- Provides real-time statistics
- User activity information
- System status monitoring
- Regenerated on every request
- Article lists
- Product information
- Statistics data
- Periodically updated with smart caching
The project uses a complete design system based on Nuxt's official green theme:
- Primary Color:
#00DC82(Nuxt Green) - CSS Variables: Unified color, spacing, and shadow system
- Responsive Design: Mobile-first layout strategy
- Component Styles: Cards, buttons, badges and other common components
- Pre-generate all pages at build time
- Static asset CDN distribution
- Image lazy loading and optimization
- CSS/JS code splitting
- Smart caching strategies
- On-demand regeneration
- Background update mechanisms
- Cache invalidation control
- Server-side data prefetching
- Client-side hydration optimization
- API response caching
- Component-level caching
Suitable for Netlify, Vercel, GitHub Pages and other static hosting services:
npm run generateSuitable for Node.js-supported server environments:
npm run build
npm run preview- Framework: Nuxt.js 4.1.3
- Frontend: Vue.js 3.5.22
- Language: TypeScript
- Build Tool: Vite
- Styling: Native CSS + CSS Variables
- Nuxt.js Official Documentation
- Vue.js Official Documentation
- Rendering Mode Comparison
- Hybrid Rendering Configuration
Welcome to submit Issues and Pull Requests!
- Fork this repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is open source under the MIT License - see the LICENSE file for details.