Author:
    Creation:2026-12-03Last update:2026-12-03

    Load Optimisation: Render Dynamic Translations Without Waiting

    Bundle optimisation decides what your users download: only the content of the current page, in the current locale. Load optimisation decides when that content arrives, so the page never has to wait for it.

    You have nothing to configure. Everything described on this page is applied automatically in production builds. You keep the same useIntlayer call, from the same import, and you never list the dictionaries a page needs.

    Table of Contents

    Why loading matters in dynamic mode

    With importMode: 'static' (the default), the content of a component is inlined in its JavaScript chunk. When the component renders, its text is already there.

    With importMode: 'dynamic', each dictionary is split into one small JSON chunk per locale. A visitor reading your site in English never downloads the French content. The trade-off is that the chunk has to be downloaded before the component can show its text.

    If nothing is done, that download only starts when the component renders. The page then goes through these steps:

    1. The route's JavaScript downloads and runs.

    2. The component renders and asks for its dictionary.

    3. The dictionary is not there yet, so the component suspends and a loading fallback (or nothing) is shown.

    4. The dictionary arrives and the component renders again, this time with its text.

    Step 3 is visible to your users. With React 19 it costs at least 300 ms: once a Suspense fallback is shown, React holds the reveal of the content for 300 ms to avoid flickering, even if the dictionary arrives 10 ms later.

    This wait can show up at three moments:

    MomentWhat happens without load optimisation
    First load (SSR + hydration)The server already rendered the text in the HTML, but the browser only discovers the dictionaries once its JavaScript runs, then waits for them before it can hydrate.
    Client navigationClicking a link renders the new page before its dictionaries arrive, so a fallback shows.
    Locale switchThe dictionaries of the new locale have to be downloaded before the text can change.

    Load optimisation removes the first two waits and keeps the third one as short as possible.

    What Intlayer does

    Whatever the framework, Intlayer applies the same three ideas:

    1. Start the download early, as soon as the code that needs a dictionary is loaded, not when the component renders.
    2. Wait for the content before showing a page, so the page never renders without its text.
    3. Use what the server knows: it rendered the page, so it can send the dictionaries it read (Next.js) or tell the browser which ones to download right away (Vite server frameworks).

    All of them start from the files Intlayer generates for each dynamic dictionary: one JSON file per locale, and an entry file mapping each locale to its loader.

    .intlayer/dynamic_dictionary/about-page.mjs (generated, simplified)
    const content = {
      en: () =>
        import("./json/about-page/en.json").then((module) => module.default),
      fr: () =>
        import("./json/about-page/fr.json").then((module) => module.default),
    };
    
    export default content;
    

    At build time, your useIntlayer call is rewritten to read that entry:

    tsx
    // Your code
    const content = useIntlayer("about-page");
    
    // After the build (simplified)
    import aboutPage from ".intlayer/dynamic_dictionary/about-page.mjs";
    
    const content = useDictionaryDynamic(aboutPage, "about-page");
    

    The framework then decides when these loaders are called and when the page can render. This is where the approaches differ.

    Vite (single-page apps)

    Applies to React, Vue, Svelte, Solid, Preact, Lit and vanilla apps built with Vite.

    1. One request per page section. At build time, Intlayer groups the dictionaries of each lazily loaded page into a single chunk per locale. A dictionary shared by several pages goes to the main chunk, or to a chunk shared only by those pages, so no page downloads another page's content.

    bash
    # Without grouping: one request per dictionary
    assets/about-page.en-a1b2.js
    assets/about-hero.en-c3d4.js
    assets/about-team.en-e5f6.js
    
    # With grouping: one request for the whole page
    assets/about.en-g7h8.js
    

    2. The download starts when the page code loads. Each dictionary entry starts loading the visitor's locale as soon as it is evaluated:

    about-page.mjs (after the Intlayer build, simplified)
    const content = { en: /* ... */, fr: /* ... */ };
    
    // Starts loading the current locale now, without blocking the module
    registerDictionaryPreload(import.meta.url, content);
    
    export default content;
    

    3. The router waits for the content. Intlayer wraps the import() calls of your app, so loading a page also loads its dictionaries, and only resolves once they are in memory:

    tsx
    // Your code
    const AboutPage = lazy(() => import("./pages/AboutPage"));
    
    // After the build (simplified)
    const AboutPage = lazy(() =>
      awaitDictionaryPreloads(
        import("./pages/AboutPage"), // the page code
        aboutPageDictionaryChunks // its dictionary chunks, per locale
      )
    );
    

    The dictionary chunks are requested at the same time as the page code, and the page renders once both are there: no fallback. If your router prefetches pages on hover, the dictionaries are prefetched too.

    4. The first page preloads from the HTML. Intlayer adds a small script to your index.html that detects the visitor's locale and preloads the dictionaries of the first page, in parallel with your main JavaScript file:

    dist/index.html (simplified)
    <script>
      // Resolves the locale (URL, cookie, browser language), then:
      // <link rel="modulepreload" href="/assets/home.fr-k9l0.js">
    </script>
    <script type="module" src="/assets/index-m1n2.js"></script>
    

    TanStack Start

    TanStack Start is built on Vite, so it gets the same optimisations as the Vite tab: grouping, download started with the page code, and import() calls that wait for the dictionaries.

    TanStack Router splits each route into its own chunk and loads it with import(). Intlayer wraps that import(), so a route only resolves once its dictionaries are loaded:

    src/routes/{-$locale}/about.tsx
    export const Route = createFileRoute("/{-$locale}/about")({
      component: AboutPage,
    });
    
    const AboutPage = () => {
      const content = useIntlayer("about-page"); // read synchronously, no Suspense
      return <h1>{content.title}</h1>;
    };
    
    Generated by the router, after the Intlayer build (simplified)
    const AboutPage = lazyRouteComponent(() =>
      awaitDictionaryPreloads(
        import("./about.tsx?tsr-split=component"),
        aboutRouteDictionaryChunks
      )
    );
    

    Client navigation. With defaultPreload: "intent", hovering a link preloads the route code and its dictionaries. The click then renders the page at once.

    src/router.tsx
    export const getRouter = () =>
      createRouter({
        routeTree,
        defaultPreload: "intent", // preloads code and dictionaries on hover
      });
    

    First load. The server renders the page with its text, and announces the dictionary chunks the page read, in the visitor's locale, in the <head>:

    HTML sent by the server (simplified)
    <head>
      <link
        rel="modulepreload"
        href="/assets/intlayer-about-194f8g-fr-Cm4jlUiY.js"
      />
      <link
        rel="modulepreload"
        href="/assets/index-ntXB9wJr.js"
        fetchpriority="low"
      />
    </head>
    

    The browser downloads them in parallel with the route code instead of discovering them once that code runs. When hydration reads the dictionaries, they are already there: no extra round trip, no fallback. This adds no JavaScript to the browser bundle; only the HTML carries one tag per chunk.

    React Router, Nuxt, SolidStart

    These frameworks are built on Vite, so they get the same build optimisations as the Vite tab: grouping, and a download started as soon as the page code loads.

    First load. As with TanStack Start, the server announces the dictionary chunks the page read, in the visitor's locale, through the framework's own head:

    FrameworkChannel
    React RouterReact 19 preloadModule, hoisted to the <head>
    NuxtNuxt's head manager, with your cdnURL or app.baseURL
    SolidStartSolid's server assets, injected in the <head>

    The browser downloads the chunks together with the page's JavaScript, so hydration does not wait for them.

    Client navigation. Nuxt and SolidStart load each page with an import() that Intlayer wraps, so the page renders once its dictionaries are there. React Router loads route modules from its own runtime: the dictionaries are requested once the route module runs, which adds one round trip to the navigation. React Router keeps the previous page on screen meanwhile, so no fallback is shown.

    Astro builds the server before the client, so the server cannot know the client chunk names, and SvelteKit has no server-side announcement yet: their pages hydrate as before, downloading the dictionaries once the island or page code runs.

    Next.js

    withIntlayer sets everything up. There is nothing to add to your components or layouts.

    next.config.ts
    import { withIntlayer } from "next-intlayer/server";
    
    export default withIntlayer({/* your config */});
    

    1. Client navigation. In the browser bundle only, Intlayer makes each dictionary entry wait for the current locale before it finishes loading:

    about-page.mjs (browser bundle, simplified)
    const content = { en: /* ... */, fr: /* ... */ };
    
    // The module finishes loading once the current locale is in memory
    await awaitDynamicEntry(content, "about-page");
    
    export default content;
    

    Next.js waits for the modules of the next page before showing it, prefetches included. The page renders with its text: no fallback. With <Link> prefetching, the dictionaries download before the click.

    2. First load (server to client transfer). The server reads the dictionaries of your client components to produce the HTML. Instead of letting the browser download them again, Intlayer sends them inside the HTML stream:

    1. During the server render, Intlayer records each dynamic dictionary read by a client component, for the current locale.
    2. It writes them into a small inline script, placed before the markup that uses them.
    3. In the browser, components read their content from that script. Hydration starts without any dictionary request.
    HTML sent by the server (simplified)
    <script>
      (self.__INTLAYER_DICTIONARIES__ ||= []).push({
        "about-page.fr": { title: "À propos", description: "..." },
      });
    </script>
    <h1>À propos</h1>
    

    The script contains only what the page actually read, in the current locale. Dictionaries read by server components are not included: their text is already in the HTML. You save the extra requests, not the bytes.

    On Next.js 14 and 15, these optimisations need webpack. Turbopack supports the browser-only rules Intlayer relies on from Next.js 16.

    Support by framework

    FrameworkGroupingEarly downloadNavigation without fallbackFirst load without waiting
    Vite (React, Vue, Svelte, Solid, Preact, Lit, vanilla)✅✅✅➖
    TanStack Start✅✅✅✅ (chunks preload)
    React Router✅✅✅ (+1 round trip)✅ (chunks preload)
    Nuxt✅✅✅✅ (chunks preload)
    SolidStart✅✅✅✅ (chunks preload)
    Astro✅✅➖❌
    Next.js 16 (Turbopack and webpack)➖✅✅✅ (content in the HTML)
    Next.js 14 and 15 (webpack)➖✅✅✅ (content in the HTML)
    Next.js 14 and 15 (Turbopack)➖❌❌❌
    • ➖: not applicable. Vite single-page apps have no server render, Astro sites navigate between full pages, and Next.js groups chunks itself.
    • SvelteKit gets the build optimisations of the Vite tab, but its navigation and hydration have not been measured yet.
    • Chunks preload: the server announces the dictionary chunks of the page, which the browser downloads with the page's JavaScript. Content in the HTML: the server sends the content itself, so the browser makes no request at all.

    Measured results

    Measured on production builds with 50 ms of network latency:

    ScenarioBeforeAfter
    Next.js 16, client navigation307 ms, with a fallback4 to 10 ms, no fallback
    Next.js 16, hydration of an SSR page~345 ms, with dictionary requests~262 ms, no request
    Vite single-page app, client navigation361 ms, with a fallback58 ms, no fallback
    TanStack Start, hydration210 ms168 ms (static: 170 ms)
    React Router, hydration181 ms137 ms (static: 135 ms)
    Nuxt, hydration241 ms185 ms (static: 184 ms)
    SolidStart, hydration192 ms133 ms (static: 128 ms)

    Hydration of the Vite server frameworks was measured over HTTP/2. The runtime cost is about 100 to 170 bytes of JavaScript per page in dynamic mode, and nothing in static mode. The chunk preloads of the Vite server frameworks add no JavaScript at all, only one <link> tag per chunk in the HTML.

    Locale switch

    When a visitor switches locale, Intlayer downloads the dictionaries of the new locale for the current page, in one request per page section, then updates the text.

    Intlayer does not preload the other locales in advance. Most visitors never change language, and preloading every locale would cancel the main benefit of dynamic mode, which is to download only the visitor's locale.

    On Next.js, the content transferred by the server for the previous locale stays in the page's HTML, but it is never shown after the switch. Each transferred dictionary is stored under its key and its locale (about-page.fr, about-page.es), so a component rendering in Spanish only reads Spanish content.

    Best practices

    • Group content by page section, not by small component. A dictionary per section of a page (header, pricing table, FAQ) keeps requests few and chunks meaningful. Several .content files can share the same key: Intlayer merges them into one dictionary.
    • Keep small, ubiquitous content static. A navigation bar or a footer shown on every page gains little from dynamic mode. Set importMode: 'static' on those dictionaries and keep 'dynamic' for long page content and applications with many locales.
    • Let your router prefetch. Prefetching a page on hover or visibility also downloads its dictionaries, so the click renders at once.
    • Check the network tab. On a production build, a client navigation should show the page's dictionary chunks downloading together with its JavaScript. A server-rendered Next.js page should hydrate without requesting any dictionary, and a TanStack Start, React Router, Nuxt or SolidStart page should list its dictionary chunks as <link rel="modulepreload"> in its HTML.
    • Serve over HTTP/2. Over HTTP/1.1, browsers open six connections per host. A page that already preloads six scripts (as Nuxt often does) delays the seventh request, whatever it is, by one round trip.

    FAQ

    No. Keep calling useIntlayer from the same package as before. On Next.js, wrapping your config with withIntlayer is enough: it installs everything described on this page.

    No. These optimisations run on production builds. In development, dictionaries are loaded on demand, which keeps rebuilds fast.

    Slightly, but by the size of content the browser would have downloaded anyway. Only the dynamic dictionaries read by client components during the server render are included, for the current locale only. Dictionaries read by Next.js server components are not included: their text is already in the HTML.

    Because the server announces them instead of sending their content: the browser downloads them, but at the same time as the page's JavaScript, so hydration does not wait for them. Sending the content in the HTML (as on Next.js) would need the server to hold the exact chunk the browser reads, while Vite server builds read the full dictionary instead.

    In spirit, yes: the server hands the data it used to the browser, so the browser does not fetch it again. The difference is that you do not write anything. Intlayer detects which dictionaries were read during the render and sends exactly those.

    Static mode does not need it: the content is already inside the JavaScript of each component, so there is never anything to wait for. Load optimisation makes dynamic mode behave like static mode on screen, while keeping its smaller downloads.