How do I use payload-types.ts in my frontend?

default discord avatar
Blankeos
last month
1

I have two separate projects:


- 1. a NextJS frontend project


- 2. a PayloadCMS project



Now, I want to consume my APIs from payload on my NextJS frontend. But I also want to query the API with type-safety. Do I just copy the types from

payload-types.ts

? What's the best way of going about this?



I also wish I knew about this template sooner:

https://github.com/payloadcms/nextjs-custom-server

Does this template make you run NextJS and Payload in a monorepo and one express server?

  • default discord avatar
    Exo
    last month

    Not sure if it is the

    best

    way, but copying

    payload-types.ts

    definitely works. Personally I like to include that step in my build process, that way I can't forget to update the types for a new deployment

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

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

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