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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite + vercel "you will need to pass in an i18next instance by using initReactI18next" #1726

Closed
laclance opened this issue Feb 21, 2024 · 2 comments

Comments

@laclance
Copy link

laclance commented Feb 21, 2024

馃悰 Bug Report

To Reproduce

I have a vite and express application that was converted from a nextjs app, deployed to vercel with no issues with nextjs.
No issues locally after switching to vite but build fails when pushed to vercel with you will need to pass in an i18next instance by using initReactI18next. I did also try just import './i18n'; without the I18nextProvider.

//i18n.ts
import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
import pos from 'locales/en/pos.json';

export const defaultNS = 'pos';
export const resources = { en: { pos } } as const;

const locizeOptions = {
  projectId: '27e7261e-cd1f-42c9-8ad9-80ad6acaa08a',
  referenceLng: 'en'
};

i18next.use(initReactI18next).init({
  resources,
  fallbackLng: 'en',
  lng: 'en',
  fallbackNS: 'pos',
  defaultNS: 'pos',
  ns: ['pos'],
  saveMissing: true,
  interpolation: {
    escapeValue: false
  },
  backend: locizeOptions
});

export default i18next;


//main.tsx

import i18n from './i18n';
import { I18nextProvider } from 'react-i18next';

...

ReactDOM.createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <I18nextProvider i18n={i18n}>
      <RouterProvider router={router} />
    </I18nextProvider>
  </StrictMode>
);

Your Environment

node 18.18
"i18next": "^23.9.0",
"react-i18next": "^14.0.5",

@adrai
Copy link
Member

adrai commented Feb 21, 2024

please provide a minimal but complete example repository...

here some hints that may help:
https://stackoverflow.com/questions/67894982/react-i18next-you-will-need-to-pass-in-an-i18next-instance-by-using-initreacti
i18next/next-i18next#1917
#1594

@laclance
Copy link
Author

Thank you, it seems vercel will not really work for our setup anyway but apps working fine on aws.

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