Currently, I am in the process of developing a miniature application using TypeScript within NextJS now that support for TypeScript comes standard in Next.js. Additionally, my aim is to integrate two recently introduced features:
Let's take a closer look at i18n
:
// next.config.js
module.exports = {
i18n: {
// These are all the locales you want to support in
// your application
// Sub-path Routing
locales: ['en', 'cn'],
// This is the default locale you want to be used when visiting
// a non-locale prefixed path e.g. `/hello`
defaultLocale: 'en',
},
}
Unfortunately, incorporating these features into my next.config.js
has proven quite challenging. While it functions as intended for regular applications (JavaScript only), I encounter the following error with the TypeScript version:
(node:15704) UnhandledPromiseRejectionWarning: TypeError: Cannot set property '__nextLocale' of undefined
If any of you have insights or can provide an example of how to effectively utilize next.config.js
and integrate these new features into a TypeScript-based NextJS application, it would be greatly appreciated.