Custom component only for non-admin users?

default discord avatar
last year
1 1

I would like to show the default components for Dashboard and Navigation if the user is an admin user and a custom component where I show only operations available to the user when a non-full admin user is logged in to the panel.

I can handle the custom components for the non-admin users, I am unsure of how to render the default component for full admin users. (I have roles set up for user = admin / organization admin / etc). Sorry if this exists elsewhere in documentation, but I'm having trouble finding if this is possible.

  • discord user avatar
    Payload Team
    last year

    Hey @ryanlanciaux

    You can definitely do this. You could import the default Dashboard and Nav components from the payload/dist folder, but I just published a beta version (payload@0.13.11-beta.0) that provides you with a more permanent way of importing those components.

    You can now import them via the following:

    import { Dashboard } from 'payload/components/views/Dashboard'
    import { Nav } from 'payload/components/elements'

    So what you'd do is provide your Payload config with custom components for the Dashboard and Nav views, perform your logic for which components to display to your logged in user, and then either render the default component or the custom component.

    How's that?

    1 reply
  • default discord avatar
    last year

    Great - thanks a ton!

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


Connect with the Payload Community on Discord



Can't find what you're looking for?

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