Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't have non serializable options in i18next in v8 #982

Closed
haggen opened this issue Feb 24, 2021 · 1 comment
Closed

Can't have non serializable options in i18next in v8 #982

haggen opened this issue Feb 24, 2021 · 1 comment

Comments

@haggen
Copy link

haggen commented Feb 24, 2021

Describe the bug

Now that i18next's options provided are serialized as JSON and sent to the client, it effectively block non serializable values like functions. @zalcode mentioned this in the Next.js 10 issue.

Occurs in next-i18next version

v8.0.0

Steps to reproduce

Provide a function value in i18next options like:

// next-i18next.config.js

module.exports = {
  i18n: ...,
  overloadTranslationOptionHandler: function() {},
};

See an error while compiling:

SerializableError: Error serializing `._nextI18Next.userConfig.overloadTranslationOptionHandler` returned from `getServerSideProps` in "/test".
Reason: `function` cannot be serialized as JSON. Please only return JSON serializable data types.

Expected behaviour

I expected i18next to be configured successfully no matter what types it accepts in its settings.

@isaachinman
Copy link
Contributor

This is specifically mentioned in the docs. You need to set serializeConfig to false and pass the config into appWithTranslation yourself.

Let me know if you have any issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants