Back to Changelog
Product Update

Nuxt Module: Caching & Route Handling

The Frontic Nuxt Module now includes intelligent caching and automatic route handling for seamless page management.

Intelligent Caching

Data fetching is optimized with Pinia Colada's stale-while-revalidate strategy:

  • Automatic Caching - Responses are cached with configurable stale times (default 5 minutes).
  • Hydration Optimized - Data fetched on the server hydrates on the client without re-fetching.
  • Smart Invalidation - Cache invalidates automatically when parameters change.
  • Configurable Per-Request - Override stale time on individual composable calls.

Route Handling

useFronticPage() handles common routing scenarios automatically:

  • Auto-Detect Slug - Call without arguments and it constructs the slug from the current URL (host + pathname).
  • 301 Redirects - When Frontic returns a 301, the module automatically calls navigateTo() with the redirect path. Disable with redirectOn301: false.
  • 404 Handling - When Frontic returns a 404, the module throws a Nuxt error. Disable with throwOn404: false to handle manually.
  • Hreflang Support - The alternates return value provides alternate URLs ready for <link rel="alternate" hreflang="..."> tags.
  • Locale Switching - The suggested return value provides the recommended URL when context changes.
// Auto-detect route and handle redirects/404s automatically
const { page, data, type, block, alternates, suggested } = useFronticPage()

// For SEO: render hreflang tags
useHead({
  link: alternates.value?.map(alt => ({
    rel: 'alternate',
    hreflang: alt.lang ?? alt.locale,
    href: alt.href,
  })) ?? []
})

Beta Update

The Nuxt Module remains in beta. These features are available now for all beta participants.

Share this update