We are just starting out on our journey of integrating with payload, coming from a background of wordpress/ACF and having many other projects with nextjs without a backend, we have been looking for a CMS exactly like payload to bring together the best of both for our projects.
We would like to use payload to power our nextjs website, it has both static and dynamic content with ecommerce elements.
What I'm wondering is, there are many approaches you can take with payload, putting payload into our nextjs repo serverlessly looks powerful for the future with the app directory powering both payload and our frontend.
However, we are not sure if that is the best way deploy, we will want dynamic elements in the near future and are not sure if this is the way forward or if we should separate payload and use payload cloud?
My current understanding is this would keep the two separated (backend repo / frontend repo), which seems more clunky for typescript typings from payload as well as deployments?
Welcome @dbssd ! Glad you found us.
There are trade-offs to each approach:
1. Payload + Next.js, serverless on Vercel. This approach is great for lightweight apps that don't do a lot of heavy-lifting. The main downside here is that you'd need to account for cold-starts that are inherent with any serverless platform.
2. Payload + Next.js deployed separately. This is typically the approach that we recommend as it offers greater flexibility in deployment platforms. The downside is like you said, you have to deal with 2 deployments.
If I were starting a large, greenfield project with Payload and Next.js. Here's how I would do it:
- Monorepo with 2 separate "apps": Payload, Next.js
- Configure a
payload-types
package within the monorepo for Payload to compile the types to.
This has the benefit of:
- Unified git history and repo tooling
- Shared types between frontend and backend
- Can utilize deploying
either projectfrom the same repo as most deployment platforms let you set the src directory (if needed for your monorepo).
is there anywhere an example for how to do the payload-types package within the monorepo? I currently just copy paste the types but if there's a way to skip that part I'd be glad
It will vary between monorepos depending on what you use to manage it. However, they'll all have the concept of a "shared package", which is where you'll configure your payload script to output to
I don't know of an example offhand
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.