Next.js Discord

Discord Forum

Adding alias for react in next.config

Unanswered
Northeast Congo Lion posted this in #help-forum
Open in Discord
Northeast Congo LionOP
Hello, I usually overwrite in the next.config the react & react-dom alias to be able to link ui library:
webpack: (config) => {
[
        "react",
        "react-dom",
        "@emotion/react",
        "@emotion/styled",
      ].forEach((item) => {
        config.resolve.alias[item] = path.resolve(
          __dirname,
          ".",
          "node_modules",
          item,
        );
      });
    return config;
}


it all works fine when using pages but when I switch to the app router it break the app. If I comment the loop is it possible to update the alias using app router?

0 Replies