Comments (7)
app/providers.tsx
'use client';
import { HubspotProvider } from 'next-hubspot';
const Providers = ({ children }) => (
<HubspotProvider>
{children}
</HubspotProvider>
)
export default Providers.
app/layout.tsx
import Providers from "./providers";
const RootLayout = ({ children }) => (
<html>
<body>
<Providers>
{children}
</Providers>
</body>
</html>
);
export default RootLayout;
Add 'use client';
to any component in which you use useHubspotForm
hook.
Everything else stays the same.
from next-hubspot.
Thanks @snelsi 👌🏼
from next-hubspot.
Hello. Will it not destroy all SSR by adding 'use client'? 🤔 I tried adding Provider only on the form containing component and it also works.
from next-hubspot.
Hello. Will it not destroy all SSR by adding 'use client'?
Hubspot form can't be server-side rendered. It requires scripts to be executed on the client side. So you should mark any component that imports and uses useHubspot
hook with use client
.
But adding Providers
component from the example above will not affect other components on your page. The children
is still rendered on the server and just passed down as a prop
from next-hubspot.
Doesn't all children automatically become client-sided if the parent has 'use client'
? My point here was that maybe it's not best to wrap it with the Provider at the very top level. 😉
from next-hubspot.
@vygandas 👇
https://nextjs.org/docs/getting-started/react-essentials#rendering-third-party-context-providers-in-server-components
from next-hubspot.
@vygandas
https://nextjs.org/docs/getting-started/react-essentials#recommended-pattern-passing-server-components-to-client-components-as-props
from next-hubspot.
Related Issues (8)
- Improve Hubspot types
- Enable SSR for Hubspot Forms HOT 2
- How to disable tracking or cookies dropped by hubspot? HOT 1
- Form not rendering with Next.js 14.0.1 HOT 10
- Two seperate forms can't be loaded twice on the same page, only one is shown? HOT 1
- Configuration option for region is not included in HubspotFormProps HOT 2
- Error with HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-hubspot.