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

Invalid next config warning in Server Components #447

Closed
EverStarck opened this issue Aug 8, 2023 · 1 comment
Closed

Invalid next config warning in Server Components #447

EverStarck opened this issue Aug 8, 2023 · 1 comment
Labels
bug Something isn't working unconfirmed Needs triage.

Comments

@EverStarck
Copy link

Description

Apparently everything works but there is a warning message in console:

- warn Invalid next.config.mjs options detected: 
- warn     The root value has an unexpected property, 0, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, configOrigin, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, modularizeImports, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactProductionProfiling, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, skipMiddlewareUrlNormalize, skipTrailingSlashRedirect, staticPageGenerationTimeout, swcMinify, target, trailingSlash, transpilePackages, typescript, useFileSystemPublicRoutes, webpack).

Mandatory reproduction URL (CodeSandbox or GitHub repository)

https://codesandbox.io/p/sandbox/next-intl-bug-template-app-forked-8g4r8r

Reproduction description

Steps to reproduce:

  1. Open reproduction
  2. See the terminal

Expected behaviour

No warning messages

@EverStarck EverStarck added bug Something isn't working unconfirmed Needs triage. labels Aug 8, 2023
@EverStarck EverStarck changed the title Invalid next config warning in ssr Invalid next config warning in Server Components Aug 8, 2023
@amannn
Copy link
Owner

amannn commented Aug 9, 2023

There seems to be a small typo in your example:

import withNextIntl from 'next-intl/plugin';

/** @type {import('next').NextConfig} */
const nextConfig = withNextIntl("./i18n.ts", {
  reactStrictMode: true,
  experimental: {
    appDir: true,
  },
});

export default nextConfig;

withNextIntl doesn't accept a second argument, but instead returns a function that accepts any custom Next.js config you might have. This is less obvious when using CommonJS, but ESM makes this very explicit.

Here's a working example:

import NextIntlPlugin from 'next-intl/plugin';

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  experimental: {
    appDir: true
  }
};

const withNextIntl = NextIntlPlugin('./i18n.ts');
export default withNextIntl(nextConfig);

Hope this helps!

@amannn amannn closed this as completed Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

2 participants