2

I'm developing a NEXT JS project and can't find a solution for a twice rendering app!

Problem

After adding rewrites to next.config.js, App is rendered twice. If remove, rendred once.

next.config.js

async rewrites() {
  return [
    {
      source: '/about',
      destination: '/',
    },
  ]
},

_app.js

function MyApp() {
  console.log('App render');

  return (<></>);
}

export default MyApp

enter image description here enter image description here

ucoder92
  • 161
  • 1
  • 11

1 Answers1

2

this should be expected behavior-- as rewrites cause double renders in nextjs

rbtmr
  • 125
  • 2
  • 6
  • 1
    Hmm... Very strange – ucoder92 May 19 '22 at 10:16
  • 1
    @ucoder92 https://github.com/vercel/next.js/issues/33028#issuecomment-1006179699 – rbtmr May 19 '22 at 10:25
  • https://github.com/vercel/next.js/issues/33028 – ucoder92 May 19 '22 at 10:28
  • https://github.com/vercel/next.js/issues/34277 – ucoder92 May 19 '22 at 10:30
  • 2
    Maintainer of repo says in your links: "This is actually expected when you have a rewrites in your config and is vaguely hinted at in the docs here: https://nextjs.org/docs/advanced-features/automatic-static-optimization" – rbtmr May 19 '22 at 10:32
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 19 '22 at 13:02