Key-value pairs as exposed state?

Is it possible to expose a state that’s a list/collection of key-value pairs? I’m thinking along the lines of a simple flat JS object with property names and values which the Bubble programmer would access like a “thing” - e.g. “exposed state’s prop1’s value” or some such.

Nothing in the plugin builder or docs seems to suggest this is possible, but I want to make sure I’m not missing something.

These key/value pairs would not be configured in the property editor, but rather generated internally within the plugin.

Any ideas?

I feel like I’m missing something here. There must be a way to expose a series of named values, no?

1 Like

Unfortunately, I do not believe this is possible even here in 2022. Of course, you can always expose a string of text that is JSON, but actually defining named keys that you can work with in the editor is a no go :frowning: Wish it was.

Would really like to see the ability to define an array of keys for visual elements. This is possible for Plugin actions but not for visual elements :cry: Or am I wrong @cal ?

Strictly speaking, that is true AFAIK. However, a couple solutions have come to light in the 3+ years since this thread was started.

  • If there are a known limited number of keys, then a custom Bubble type (that’s not tied to the DB) can be defined. This results in the best Bubble developer experience. I’ve used this approach in published plug-ins.

  • If the key names or number of key/value pairs can vary, a simple “cheater” approach is to publish a list of delimited strings as an exposed state (the 2nd option described here). It makes use of the :split by operator (which wasn’t available at the time this thread was created). It’s super simple and flexible, but it’s not the most elegant approach if you plan to distribute the plugin.


ah I’ve always solved this problem by importing the JSON as a string into bubble and then JSON.parse() it into a JS object. Every key-value pair is available from there.

Some JS is needed to take each item’s key-value pair and save it onto a custom state, which can then be transferred to the bubble database.

1 Like

Yes, I’ve seen that technique mentioned elsewhere. However, I’m a bit of a “purist” and don’t like “polluting” my Bubble environment with JS. The only JS in my apps resides inside plug-ins; but that’s just my personal philosophy. :slightly_smiling_face:


Unfortunately the intention was to make a distributable plugin :cry:

Does seem a bit odd that plugin actions offer this but visual elements do not.

1 Like