Issues with payload in Next.js using the 'next-payload' plugin

default discord avatar
3 months ago

I just can't get it to work properly. Every HMR (hot reload) on a component that imports the payload client (the


you get

from next-payload install

) crashes the app with the following error:

Unhandled Runtime Error

Error: Cannot overwrite _preferences model once compiled.

This seems to have something to do with mongoose used internally by payload

  • default discord avatar
    3 months ago

    Hey @teamkube welcome in - this issue has been mentioned previously here:

    Though, I don't seen a resolution posted...

    Seems like a version error? And yes, related to the preference collection

    The version chart posted by @zeniodev lists where this issue occurs,

    13.4.0 ✅ works

    13.4.1 ✅ works

    13.4.2 ✅ works

    13.4.3 ✅ works

    13.4.4 ⚠️ Cannot overwrite _preferences model once compiled.

    Does someone from the Payload team have any additional information regarding this issue?

  • default discord avatar
    3 months ago

    I tried the version used by the demo application

    13.2.4-canary.6 that is a lot older than 13.4.3

    maybe something got cached, ill try again with 13.4.3

  • default discord avatar
    3 months ago

    I will look into this today

  • default discord avatar
    3 months ago

    setting Next to 13.4.3 + deleting ./next , ./node_modules and my package.lock solved it

    thanks a lot

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.