Skip to content

Fluent.js usage example for SSR (server-side rendering) on Next.js and other React based frameworks #646

Open

Description

@MurzNN

I want to use the Fluent.js library inside a Next.js application on the server-side rendered components, not only on the React frontend client-side components.

This support is introduced in the PR #233 and documented here: https://github.com/projectfluent/fluent.js/wiki/React-Overlays#custom-markup-parsers

But I still can't make this work well - maybe something got changed from that time.

So, could you please provide a working example of the Fluent i18n integration with Next.js that works on the server side? Thanks!

Activity

  1. MurzNN commented on Sep 1, 2025

    @MurzNN
    Author

    Here is an example of the error, when I am trying to do the same as in the documentation:

     ⨯ TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_0__.createContext) is not a function
        at __webpack_require__ (.next/server/webpack-runtime.js:33:43)
        at __webpack_require__ (.next/server/webpack-runtime.js:33:43)
        at __webpack_require__ (.next/server/webpack-runtime.js:33:43)
        at eval (webpack-internal:///(rsc)/./src/app/(frontend)/layout.tsx:22:72)
        at __webpack_require__.a (.next/server/webpack-runtime.js:100:13)
        at eval (webpack-internal:///(rsc)/./src/app/(frontend)/layout.tsx:1:21)
        at <unknown> (rsc)/./src/app/(frontend)/layout.tsx (/var/www/html/.next/server/app/(frontend)/page.js:63:1)
        at Function.__webpack_require__ (.next/server/webpack-runtime.js:33:43) {
      page: '/'
    }
     GET / 500 in 828ms
    
  2. changed the title [-]Fluent.js usage example for SSR (server-side rendering) on Next.js and other frameworks[/-] [+]Fluent.js usage example for SSR (server-side rendering) on Next.js and other React based frameworks[/+] on Sep 1, 2025
  3. eemeli commented on Sep 1, 2025

    @eemeli
    Member

    You appear to be hitting this problem: https://nextjs.org/docs/messages/context-in-server-component

    Unfortunately I'm not aware of a current SSR use of fluent.js internally at Mozilla, and I haven't worked with Next.js for quite a few years now, so I'm not sure how to help further on this.

  4. MurzNN commented on Sep 2, 2025

    @MurzNN
    Author

    Yes, the problem is exactly with the dependency on the client-side component, which I'm trying to resolve, to get translations on the backend. So, maybe the author of that feature, @stasm can help with resolving the issue?

  5. MurzNN commented on Sep 2, 2025

    @MurzNN
    Author

    Also, found a project https://github.com/devgioele/next-fluent that have a working example, but it is pretty outdated - will try to reuse the approach from there too.

  6. vito-torrentino commented on Jan 31, 2026

    @vito-torrentino

    Does Fluent even require a custom html parser on server in modern react?
    Surely with all the server render support something can be done the React Way™.
    Although, looking at a similar component in react-i18next, it uses html-parse-stringify, but at least it works on server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions