Loris Sigrist looking very handsome Loris Sigrist

Building an i18n library for the modern Web

Over the last few years we’ve seen the emergence of “partial hydration” patterns across many frameworks. The idea is that most rendering happens on the server, with only the interactive parts of a page actually shipping code to the client. The client and server cooperate to show a user a site. This idea has come in many iterations, be it React Server Components, Astro Islands, or even HTMX.

This has some interesting implications for i18n libraries.

The Status Quo

Most i18n libraries are still conceptualised as monoliths that do all the work in the same place. Language Detection, Message Fallbacks, Lazy Loading & so many more features. However, doing all the work in one place usually means doing it twice! Once on the server and again on the client. This has resulted in some truly impressive bundle sizes. i18next, one of the most popular i18n libraries needs over 40kB to render a single message. This is after bundling.

Clearly there is a lot of room for improvement.

A modern i18n library

What would an i18n library look like that embraces the cooperation between Server and Client, that’s built for partial hydration?

That’s exactly what we tried to accomplish with ParaglideJS

Paraglide is a compiler that compiles your messages into JS modules. Each message is it’s own export.

//Paraglide's output

 * @param {{ name: string }} params
export const greeting = (params) => `Hello ${params.name}`

export const my_other_message = () => `My Other Message`
// ...

This takes advantage of modern tooling.

  1. TypeScript. Messages are fully type-safe, including any parameters they take. This makes Paraglide a joy to use for templating.
  2. Modern Build tools remove JS code that isn’t used automatically. Because messages are individual JS exports, they can individually be removed if they aren’t used. This automatically only ships messages that are needed on the client. This results in some tiny bundle-sizes, starting as low as 100 bytes.

We can further take advantage of the cooperation between server and client to skip language detection on the client entirely. Because the server already decided which language to render, the client bundle can just read which language was used from the HTML.

Because ParaglideJSis a compiler, fallback messages can be resolved at build time, so no runtime code is needed for that.

So far, this approach is working very well in any partial-hydration setting. However, even in frameworks without partial hydration ParaglideJS can still be useful. It still only ships messages that are used on a given page without you needing to manually split messages into namespaces as you usually would.


Going forward, scaling down and integration with modern tooling is going to be increasingly important for i18n libraries. ParaglideJS is one attempt at this which can be used today. Clearly there is a lot of room for innovation in this space & we’re interested in how it will develop over the next few months and years.