Accessing current state from plugin

Hello, i want to ask what is the best way to access content connected data ?
I am trying to use
const currentState = (window as any).builder?.state?.toJSON();

I can access atleast key but dont see the entry i set there so still the filter is not optimal, atleast I could fetch it use builder content API but i see problem with reactivy because the previous one connected model is still there so i need refresh so this is not very UX friendly.

The purpose of this is to use data binded fields in our custom editor so we can dynamically set text so we can manage it on on place

Can you please suggest what is the best way ?

Also i tried to access state using {{}} and i cant see it my Text, i tried to remove all plugins and custom components and yet not working. Any idea what could be done ? I did not find much about it

Hello @matuskocian,

If you’re working with connected data and the state object has a named entry like blogArticle, you can retrieve it more directly using:

const articleState = window.builder?.state?.get('blogArticle')?.toJSON();

Thanks for anwser, this information i already know. Problem is that if i try to use {{}} in Text Component its not working. The other issue i would like to know the current Connected Data using builder.io bultin plugin.

Hello @matuskocian,

Just to clarify — support for {{ state.something }} is typically limited to Builder’s built-in components like Text, RichText. Custom components generally require using JavaScript bindings instead of string interpolation.

If you’re unable to utilize the data binding features as expected, could you please provide a bit more context around your use case? For example:

  • Are you working with connected data or manually passing state?
  • Which component are you trying to bind the value to?
  • Is this behavior inside the visual editor or during rendering?

If possible, a short screen recording or example configuration would really help us troubleshoot more effectively.

Looking forward to your response so we can assist further.

Best regards,

So basically according to using state on docs, you should be able by using {{}} parse the state component
Its simple text component. Maybe i misunderstond something

Helo @matuskocian

Usually {{ state.something }} when using with builder text component should work as expected.

Could you please provide me with the Builder Content Entry link where you’re experiencing an issue? This will help me further my investigation.

Here is how to find it:

This is the model from where i want the data 0e63819fb2384d4b8ee0aa23ae76a956_1f2f9cabbd3049218dcf67ac70626748

this is the page
0e63819fb2384d4b8ee0aa23ae76a956_5ce8868d97fc4036b278488b2638d23e/edit?activeDesignerTab=0&selectedBlock=builder-3cdb44cdff4049a2bb9400d6b18e57dc&activeLocale=Default

To better knowledge what i am trying to acchieve is in our custom rich text editor make dynamic inline data bindings. That means we will make selection of fields in builderio data-bindings and be able to select field and wrap in curly braces. The wish is to automatically parse it if its possible, if not we can do it manually but trying to use as much builtin services as possible

Hello @matuskocian,

Thank you for sharing more context around what you’re trying to achieve.

From what I understand, you’re aiming to enable dynamic inline data bindings within a custom rich text editor — specifically allowing users to select fields from Builder.io’s data bindings and wrap them in curly braces (e.g., {{ state.something }}), ideally with automatic parsing.

Just to clarify, parsing {{ state.something }} inline is not natively supported when using a custom rich text editor or with a custom component of type RichText. The default Text component supports such bindings, but this behavior doesn’t automatically extend to custom implementations.

That said, if automatic parsing isn’t feasible, your approach to manually handling it is valid — and we definitely encourage leveraging as much of Builder’s built-in functionality as possible where it makes sense. If you’d like, we’re happy to help review your current setup and explore possible workarounds or enhancements that could better support your use case.

Let us know how you’d like to proceed.

Thanks,

I found several adjustments that would be very nice to check.

If i specify DataModel fields and than create entry with those fields and than delete those fields from DataModel the state it still reflects like those fields exists even though i cant edit or remove it from DataEntry.

Next things is if i remove dataSource and add other one, there are suddenly 2 states till i refresh after that the old one which was removed is also removed from state.

It would be nice to have it more responsive

Hello @matuskocian,

Thank you for sharing your observations — they’re very helpful.

What you’re seeing is related to aggressive caching in the current implementation. Updates to the DataModel or dataSources may take a few minutes to fully reflect in the UI.

For example, when switching dataSources, the state may temporarily show both the old and new sources until a manual refresh is performed. We understand this can be confusing and may lead to inconsistent behavior.

We’re actively working on improving this experience to make state updates more responsive and minimize the need for manual intervention.

Thanks again for your feedback — it’s valuable and helps us prioritize enhancements. Let us know if you notice anything else or have further questions.

Thanks,