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.

Storing global state in admin panel

default discord avatar
sandrowegmann2 years ago
7

I'd like to use a global state library such as redux or jotai within the admin panel. The goal is to persist specific settings across all views, without saving them to the database. Is this possible?

  • default discord avatar
    ibrahem11052 years ago

    you can use config.providers if your state manager has a provider

  • default discord avatar
    sandrowegmann2 years ago

    Ah yep, guess that's it. I'll experiment a bit, thanks! 🙂

  • default discord avatar
    aaronksaunderslast year

    did you get this working? trying to see if this is straight forward or if i need to bring in zuzstand or pullstate

  • default discord avatar
    sandrowegmannlast year

    Hey man, we ended up with a custom provider & jotai. Works pretty well so far, I was actually planning to release a YT video about it in the coming days!

  • default discord avatar
    aaronksaunderslast year

    i have finished the custom provider, now i just need to figure out how to access the data in it...



    the problem is i need the data in a collect hook, and I think the only way to do that is by creating a custom component.... which seems like too much work

  • default discord avatar
    sandrowegmannlast year

    What exactly are you trying to achieve?

  • default discord avatar
    aaronksaunderslast year

    Share content between pages, basically call a function in my context from any page without all of my pages being custom. I don’t know where to call the usecontext hook since hooks can only be called in functions

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.