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.

TypeError Generating Types with @payloadcms/ui Imports

discord user avatar
alessiogr
last year
4
@330920438110879766

importing from

@payloadcms/ui

in your Payload Config is not allowed, as you're bringing client-side files into your Payload Config, which is server-only. You can only import from

@967091941873426493

/ui in client-side components that are not directly imported by the Payload Config

  • default discord avatar
    manolocaplast year

    oh then, that is the error.


    I am importing it to use it on a custom field.


    The custom Field is used in a collection and the collection is imported in the payload config.



    Which should be the Payload way then? I wanted to use useField to get the state of a previous field

  • default discord avatar
    arcayne.last year

    You should still be able to use

    useFormField

    inside of your custom field component file.

  • default discord avatar
    zed0547last year
    @330920438110879766

    Can you share how you're defining the custom component in your config?



    You should be passing a path to the component - it sounds like you are importing this component directly

  • default discord avatar
    manolocaplast year

    I think the problem was that I had my component inside /src/fields/.../component.ts



    I checked this source code:

    https://github.com/aaronksaunders/payload-custom-text-field-1-2025/blob/main/src/collections/Users.ts

    Putting the component inside the collection folder and importing them like this:



    {


    name: 'fullName',


    type: 'text',


    admin: {


    readOnly: true,


    components: {


    Field: '@/collections/CustomFields/CustomFullNameTextFieldClient',


    },


    },


    },




    no more issues generating types, the importmap or running the app and using payload ui



    thank you!

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.