Krzysztof Żuraw

Migrating Next.js plugins from next-compose-plugins

I recently updated Next.js to version 12.2.3 and I found out that next-compose-plugins do not work anymore. After peek at GitHub issue and I was able to copy and paste working solution:

/**
* @type {import('next').NextConfig}
*/

module.exports = () => {
const plugins = [withTM, withVanillaExtract, withSentryConfig];
return plugins.reduce((acc, next) => next(acc), {
i18n: {
locales: ["en-US", "nl-BE", "pl-PL"],
defaultLocale: "en-US",
},
});
};

It worked fine but I wanted to pass argument to withSentryConfig - i turns out that I need to pass it as another argument to next function in reduce:

return plugins.reduce((acc, next) => next(acc, {silent: true }, {
// the rest of next.js config
});