1

Error: i18n support is not compatible with next export.

I get this error every time I try to build code on github. It says:

Error: i18n support is not compatible with next export. See here for more info on deploying: https://nextjs.org/docs/deployment at /home/runner/work/sprenty-front/sprenty-front/node_modules/next/dist/export/index.js:144:19 at async Span.traceAsyncFn (/home/runner/work/sprenty-front/sprenty-front/node_modules/next/dist/trace/trace.js:79:20) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. Error: Process completed with exit code 1.

This is error

This is my code in next.config.js:

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
  i18n: {
    locales: ['ka', 'en'],
    defaultLocale: 'ka',
  },
  images: {
    domains: []
  }
}

module.exports = nextConfig

This is my code in pages/index.tsx:

import type { NextPage } from 'next'
import Head from 'next/head';
import Image from 'next/image';
import useLang from '../hooks/useLang'

const Home: NextPage = () => {
  const t = useLang();
  return (
    <div>
      <Head>
        <title>{t.appTitle}</title>
      </Head>
    </div>
  )
}

export default Home

I call useLang hook as a t variable, which is responsible for understanding the locale and getting the language accordingly (/ka, /en)

This is useLang:

import { useRouter } from "next/router";
import ka from "../lang/ka"; //Georgian language file (.js)
import en from "../lang/en"; //English language file (.js)

export default function useLang() {
  const router = useRouter();
  const { locale } = router;
  const usedLanguage = locale === "ka" ? ka : en;
  return usedLanguage;
}

Code is working perfectly with no errors, but during build, it gives me the given error

B3K4
  • 47
  • 7
  • 1
    As the error mentions, `next export` does not support i18n routing. See [i18n support is not compatible with next export. (SSR - NextJS 10)](https://stackoverflow.com/questions/65513435/i18n-support-is-not-compatible-with-next-export-ssr-nextjs-10) and https://nextjs.org/docs/advanced-features/static-html-export#unsupported-features. – juliomalves Aug 03 '22 at 06:50

0 Answers0