I'm attempting to insert this script into the Head section of my NextJS project:
<script>
hbspt.forms.create({
region: "na1",
portalId: "XXXXXX",
formId: "XXXXXX"
});
</script>
However, I encounter two errors:
Error 1: Unexpected token. Did you mean {'}'}
or }
?ts(1381) (pertaining to closing brackets)
Error 2: Syntax error: Unexpected token, expected "}" (in the line "region: "na1")
This snippet is from the indes.jsx file:
import Head from "next/head";
import styled from "styled-components";
import HeroSection from "../components/sections/HeroSection";
import OverviewSection from "../components/sections/OverviewSection";
const Wrapper = styled.div`
margin-top: 10rem;
`;
export default function HomePage() {
return (
<Wrapper>
<Head>
<title>Code Shape - Home</title>
<link rel="icon" href="/favicon.ico" />
<script
type="text/javascript"
id="hs-script-loader"
async
defer
src="//js.hs-scripts.com/8205013.js"
></script>
<script
charset="utf-8"
type="text/javascript"
src="//js.hsforms.net/forms/shell.js"
></script>
<script>
hbspt.forms.create(
{
region: "na1",
portalId: "XXXXXX",
formId: "XXXXXX",
}
);
</script>
</Head>
<HeroSection />
</Wrapper>
);
}
The script is sourced from HubSpot during form generation, so it should be correctly formatted.