builder icon indicating copy to clipboard operation
builder copied to clipboard

Custom code with data binding not rendering properly server side

Open tristanoneil opened this issue 1 year ago • 0 comments

Describe the bug We have a Builder page that has an element with an HTML attribute that is bound to a custom code block. This works fine when rendered client side and results in something like data-swiper-options="{"some": "json"} but when it's rendered server side it results in data-swiper-options="[object Object]". This poses a problem because we're mounting BuilderComponent client-side using hydrate and it's not re-rendering the HTML so data-swiper-options="[object Object]" remains.

To Reproduce Steps to reproduce the behavior:

  1. Create a builder page that includes an element with an HTML attribute that is bound to custom code that looks like:
const options = `{
  "some": "json"
}`

export default options;
  1. Render this page server side using @builder.io/react version 8.0.9 (we're just using Node 20.18.3 with renderToString)
  2. 💥 See that the HTML produced does not properly return executed custom code but instead [object Object] -- presumably a representation of the actual custom code instead of the result of it's execution.

Expected behavior Custom code should be executed server side resulting in the proper HTML output.

Additional context I've created a page where this is reproducible in my Builder space here: https://builder.io/content/f8608641b0604e938a2a50965af27017/edit

I've noticed that this does work when the page is rendered using the HTML API, so theoretically this should be supported.

I've noticed that this scenario also seems to break the JSX editor in the Builder editor. It results in the following when you click "Toggle JSX Editor":

Image

tristanoneil avatar Mar 08 '25 12:03 tristanoneil