Skip to main content
InterviewHubPRO
Section Overview
Q46

Question 46 of 50

Part 3: Advanced Internals, Performance & Production (Senior / Staff)

92%
Nuxt & Universal SSR (50 Qs)•Part 3: Advanced Internals, Performance & Production (Senior / Staff)

Nuxt 3 Hybrid Rendering with `routeRules`.

senior LevelCode ExampleRoutingFormsPerformance

In Simple Words: Instead of choosing one rendering mode for the whole app, routeRules in nuxt.config.ts configures rendering behavior per route:

  • ssr: false: Client-side single page app (SPA) for dashboard pages.
  • prerender: true: Static Site Generation (SSG) at build time for marketing pages.
  • swr: 3600: Stale-While-Revalidate caching (revalidates in background after 1 hour).
  • redirect: '/new': Permanent 301/302 redirects handled at edge.
typescript
// nuxt.config.ts
export default defineNuxtConfig({
  routeRules: {
    '/': { prerender: true },              // Pre-rendered at build time
    '/blog/**': { swr: 3600 },             // Cached on CDN, regenerated hourly
    '/admin/**': { ssr: false },           // Client-only SPA mode
    '/api/**': { cors: true },             // Automatically append CORS headers
  }
});