Skip to content

Conversation

rjgtav
Copy link
Contributor

@rjgtav rjgtav commented Oct 14, 2025

What?

Forces pg-cloudflare dependency to be installed, even when using pnpm install

Why?

When using the db-postgres adapter inside Cloudflare, it needs the pg-cloudflare package to work, which is an optional dependency of pg. This is necessary to support connecting to a Postgres database, via Cloudflare's Hyperdrive, when deploying Payload on Cloudflare.

Optional dependencies are installed by default when using npm, but not when using pnpm.

How?

By declaring pg-cloudflare as a dependency of db-postgres.
To help with the bundling, it's also necessary to add pg-cloudflare to the list of Next.js' external dependencies. More info here: https://opennext.js.org/cloudflare/howtos/workerd#configuration

Discord discussion: https://discordapp.com/channels/967097582721572934/1427199951766552586

return webpackConfig
},

serverExternalPackages: ['pg-cloudflare'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add this to the D1 template, which is currently being used as a base to implement Payload using Postgres with Hypedrive, or should this just go into the documentation, in a dedicated section?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant