Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

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

default discord avatar
Blankeos2 years ago
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
    Exo2 years ago

    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

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.