# Hydration error when using SSG with Custom Code component

**URL:** <https://forum.builder.io/t/hydration-error-when-using-ssg-with-custom-code-component/6523>\
**Category:** Technical Questions\
**Tags:** nextjs\
**Created:** [October 4, 2024, 4:42am UTC](https://forum.builder.io/t/hydration-error-when-using-ssg-with-custom-code-component/6523 "2024-10-04T04:42:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yongjie\_glints](https://avatars.discourse-cdn.com/v4/letter/y/ecc23a/32.png) [@yongjie\_glints](https://forum.builder.io/u/yongjie_glints)\
**Post date:** [October 4, 2024, 4:42am UTC](https://forum.builder.io/t/hydration-error-when-using-ssg-with-custom-code-component/6523/1 "2024-10-04T04:42:17Z")

</div>

_Please fill out as many of the following questions as possible so we can help you promptly! If you don’t know how to answer or it does not apply, feel free to remove it or leave it blank._

**Builder content link**

> **[Builder.io: Visual Development Platform](https://builder.io/content/c51bdbcdbc9849adbafd20532109b687)**
>
> Drag and drop with your components, right within your existing site or app. Build and optimize digital experiences for any tech stack, visually..

**Builder public api key**  
6aedcdfa7b4a48d6869d32835be21d2e

**What are you trying to accomplish**  
I’m trying to integrate a HubSpot Form onto a page, but am encountering hydration errors.

**Code stack you are integrating Builder with**  
React/Next.js (static export)

**Reproducible code example**  
First, insert a “Custom Code” component to the page with the following contents.

```auto
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js"></script>
<script>
  hbspt.forms.create({
    region: "na1",
    portalId: "3060771",
    formId: "ac0ee37b-c3b5-4b41-95a2-bcfc67f3f635"
  });
</script>

```

With the “Scripts client only” option turned on, I get this hydration error, and the HubSpot form doesn’t show up.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/0/0540aa1c70381b28010da8e98c5bbfee81bf4cae.jpeg)

With the “Scripts client only” option turned off, I get this hydration error, and the HubSpot form does show up:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/7/769023fdbef7f942f702341030ee7287143caef1.jpeg)

Reading the source code for the Custom Code block, it seems that I’d actually need something in between “Scripts client only” turned on and “Scripts client only” turned off.

If my understanding is correct:

- When “Scripts client only” is turned on, the script tag is only injected after hydration occurs. It doesn’t appear in the server markup.
- When “Scripts client only” is turned off, the script tag is injected _and_ evaluated on the server side.

The behaviour I seem to need is: The script tag is injected into the server markup, but not evaluated on the server side. It doesn’t seem possible to do with the current Custom Code component.

---

<div class="post-metadata">

**Author:** ![sheema](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@sheema](https://forum.builder.io/u/sheema)\
**Post date:** [October 7, 2024, 12:44pm UTC](https://forum.builder.io/t/hydration-error-when-using-ssg-with-custom-code-component/6523/2 "2024-10-07T12:44:51Z")

</div>

Hey, @yongjie_glints, I can see the issue is resolved for you using the[Custom Components](https://www.builder.io/c/docs/custom-components-intro). Is this something you would still like to look into? Looking at your use-case, I recommend using the custom components.
