Skip to content
← All questions
⚡ Intermediate

How does hybrid rendering (route rules) work in Nuxt?

💚 Nuxt🖥️ SSR⚡ Performance

Hybrid rendering lets you mix rendering strategies per route in the same Nuxt app. A marketing page can be prerendered at build time, the blog can use ISR, and the admin panel can be client-only. You configure all of this in routeRules.

routeRules in nuxt.config.ts ​

ts
export default defineNuxtConfig({
  routeRules: {
    '/': { prerender: true },
    '/about': { prerender: true },
    '/blog/**': { isr: 3600 },
    '/admin/**': { ssr: false },
    '/api/**': { cors: true }
  }
})

Each key is a route pattern. Glob patterns (**) match nested paths.

Available rules ​

RuleWhat it does
prerender: trueGenerate static HTML at build time
ssr: falseClient-side only (SPA for that route)
isr: numberIncremental Static Regeneration, cache for N seconds
swr: number | trueStale-While-Revalidate, serve stale and refresh in background
cache: { maxAge: number }Server response cache with TTL
redirect: stringHTTP redirect
cors: trueAdd CORS headers
headers: objectCustom response headers
Decision tree for choosing Nuxt hybrid rendering strategy based on SEO needs and content freshness

When to use each strategy ​

Prerender for content that changes at deploy time:

ts
routeRules: {
  '/': { prerender: true },
  '/pricing': { prerender: true },
  '/docs/**': { prerender: true },
}

ISR for content that changes periodically but doesn't need to be real-time:

ts
routeRules: {
  '/blog/**': { isr: 3600 },       // rebuild every hour
  '/products/**': { isr: 600 },    // rebuild every 10 minutes
}

The first request after the cache expires triggers a background regeneration. Users always get a fast cached response.

SWR is similar to ISR but always serves the stale version while revalidating:

ts
routeRules: {
  '/feed': { swr: true },           // default TTL
  '/leaderboard': { swr: 300 },     // 5-minute window
}

Client-only for pages behind authentication or with no SEO need:

ts
routeRules: {
  '/admin/**': { ssr: false },
  '/dashboard/**': { ssr: false },
}

Inline route rules (per page) ​

Instead of configuring everything in nuxt.config.ts, you can define rules directly in the page:

vue
<!-- pages/about.vue -->
<script setup>
defineRouteRules({
  prerender: true
})
</script>

This keeps the rendering strategy next to the page that uses it.

Combining rules ​

Rules can stack. A route can have caching, headers, and CORS at the same time:

ts
routeRules: {
  '/api/public/**': {
    cors: true,
    cache: { maxAge: 60 },
    headers: { 'X-Custom': 'value' }
  }
}

ISR vs SWR vs prerender ​

prerenderISRSWR
When HTML is generatedBuild timeFirst request, then on intervalFirst request, then on interval
Stale content shownNever (until next deploy)Only while regeneratingAlways (refreshes in background)
Needs a serverNo (static files)YesYes
Good forLanding pages, docsBlog posts, product pagesFeeds, dashboards

See also: What are the rendering modes in Nuxt? · How do you deploy a Nuxt app? · How does data fetching work in Nuxt?

References ​

Released under the MIT License.