Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Add server-announced chunk preloads for TanStack Start, React Router, Nuxt and SolidStart"v9.10.003/12/2026
- "Init doc: chunk grouping, early preload, navigation wait and Next.js server-to-client transfer"v9.10.003/12/2026
The content of this page was translated using an AI.
See the last version of the original content in EnglishIf you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
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:
The route's JavaScript downloads and runs.
The component renders and asks for its dictionary.
The dictionary is not there yet, so the component suspends and a loading fallback (or nothing) is shown.
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:
Open the table in a modal to view all data content clearly
| Moment | What 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 navigation | Clicking a link renders the new page before its dictionaries arrive, so a fallback shows. |
| Locale switch | The 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:
- Start the download early, as soon as the code that needs a dictionary is loaded, not when the component renders.
- Wait for the content before showing a page, so the page never renders without its text.
- 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.
Copy the code to the clipboard
At build time, your useIntlayer call is rewritten to read that entry:
Copy the code to the clipboard
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.
Copy the code to the clipboard
2. The download starts when the page code loads. Each dictionary entry starts loading the visitor's locale as soon as it is evaluated:
Copy the code to the clipboard
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:
Copy the code to the clipboard
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:
Copy the code to the clipboard
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:
Copy the code to the clipboard
Copy the code to the clipboard
Client navigation. With defaultPreload: "intent", hovering a link preloads the route code and its dictionaries. The click then renders the page at once.
Copy the code to the clipboard
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>:
Copy the code to the clipboard
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:
Open the table in a modal to view all data content clearly
| Framework | Channel |
|---|---|
| React Router | React 19 preloadModule, hoisted to the <head> |
| Nuxt | Nuxt's head manager, with your cdnURL or app.baseURL |
| SolidStart | Solid'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.
Copy the code to the clipboard
1. Client navigation. In the browser bundle only, Intlayer makes each dictionary entry wait for the current locale before it finishes loading:
Copy the code to the clipboard
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:
- During the server render, Intlayer records each dynamic dictionary read by a client component, for the current locale.
- It writes them into a small inline script, placed before the markup that uses them.
- In the browser, components read their content from that script. Hydration starts without any dictionary request.
Copy the code to the clipboard
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
Open the table in a modal to view all data content clearly
| Framework | Grouping | Early download | Navigation without fallback | First 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:
Open the table in a modal to view all data content clearly
| Scenario | Before | After |
|---|---|---|
| Next.js 16, client navigation | 307 ms, with a fallback | 4 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 navigation | 361 ms, with a fallback | 58 ms, no fallback |
| TanStack Start, hydration | 210 ms | 168 ms (static: 170 ms) |
| React Router, hydration | 181 ms | 137 ms (static: 135 ms) |
| Nuxt, hydration | 241 ms | 185 ms (static: 184 ms) |
| SolidStart, hydration | 192 ms | 133 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
.contentfiles 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.
