Reputation: 21
So i've added the generateStaticParams to my app/[locale]/layout.tsx file and unstable_setRequestLocale to all the layout and page files refering to the next-intl docs
and i get the following error while github tries to build it.
Injecting property=output and value=export in:
import createNextIntlPlugin from 'next-intl/plugin';
const withNextIntl = createNextIntlPlugin();
/** @type {import('next').NextConfig} */
const nextConfig = {};
export default withNextIntl(nextConfig);
Error: TypeError: error must be an instance of Error
my app/[locale]/layout.tsx looks like this:
import { Inter } from "next/font/google";
import "./globals.css";
import {NextIntlClientProvider} from 'next-intl';
import {getMessages} from 'next-intl/server';
import {unstable_setRequestLocale} from 'next-intl/server';
const locales = ['en', 'pt'];
export function generateStaticParams() {
return locales.map((locale) => ({locale}));
}
const inter = Inter({ subsets: ["latin"] });
export default async function RootLayout({
children,
params: {locale},
}: Readonly<{
children: React.ReactNode;
params:{
locale: string;
}
}>)
{
unstable_setRequestLocale(locale);
const messages = await getMessages();
return (
<html lang={locale}>
<body className={inter.className}>
<NextIntlClientProvider locale={locale} messages={messages}>
{children}
</NextIntlClientProvider>
</body>
</html>
);
}
it says i need to call this function in every layout and page files, but in my main (/app/[locale]/page.tsx) file, i can't call it since i'm using "use client".
so in dev build it works fine, but once i try to push it to github it throws me that error.
i'm sorry if this is not enough information, i'm new to nextjs.
Upvotes: 2
Views: 657
Reputation: 31
if you are using the standard NextJS workflow by Github Action (https://github.com/actions/starter-workflows/blob/main/pages/nextjs.yml) I solved the issue removing the option:
with:
static_site_generator: next
I found the solution on this github issue: https://github.com/actions/configure-pages/issues/107.
Upvotes: 3