// `/feed-swr` — ISR with `staleWhileRevalidate`. When the `revalidate` window // expires, instead of blocking the next visitor on a fresh render, the cache // serves the STALE HTML immediately AND kicks off a background re-render. The // visitor never waits; the cache catches up out-of-band. import type { ReactNode } from 'react' import { useLoaderData, type LoaderFn, type PageMeta } from '@voltro/web' import { T } from '@voltro/i18n' import { getCatalog } from '../../locales/index' export const renderMode = 'isr' as const export const revalidate = '5 seconds' // Within this window AFTER `revalidate` expires, requests get the STALE HTML // instantly + a background refresh runs. Beyond (revalidate + swr) the next // request blocks on a fresh render, like plain ISR. export const staleWhileRevalidate = '30 seconds' // Locale-aware tab title + description (cookie-i18n — @voltro/web hands meta // the active locale). export const meta = ({ locale }: { readonly locale: string }): PageMeta => ({ title: getCatalog(locale)['meta.swr.title'], description: getCatalog(locale)['meta.swr.description'], }) interface SwrData { readonly renderedAt: string readonly nonce: number } export const loader: LoaderFn = async () => ({ renderedAt: new Date().toISOString(), nonce: Math.floor(Math.random() * 1_000_000), }) export default function FeedSwr(): ReactNode { const data = useLoaderData() const code = (c: ReactNode) => {c} return (

  • {data.renderedAt}
  • {data.nonce}

) }