Framework Guides
Exported components are designed to be framework-agnostic, but each framework has its own conventions and best practices for integration. This guide provides specific considerations for popular React frameworks.
Regardless of the framework you’re using, follow these patterns to successfully integrate DevLink:
Ensure your import paths correctly resolve to your DevLink directory. Adjust import paths based on your project structure (for example, @/DevLink
, ~/DevLink
, or relative paths).
DevLink components are fully compatible with server-side rendering. Just make sure to wrap your application with DevLinkProvider at the root level.
Some frameworks may need configuration to prevent duplicate CSS imports. Use each framework’s recommended approach for CSS management.
DevLink generates type definitions for each Webflow component. Ensure your tsconfig.json
includes the DevLink directory *.ts
files.
React Server Components
Exported components, which often rely on client-side JavaScript for interactions and styling, may not work directly with React Server Components (RSC). To use Webflow components in your React application, it’s recommended to:
- Use exported Webflow components only within client components.
- Mark the React component consuming the exported Webflow component as a client component by adding the
"use client"
directive to the component file. - Make sure the
DevLinkProvider
is in a client-side context (e.g., within alayout.tsx
file marked as a client component) to enable all interactions.
Next.js
Next.js, with its server-side rendering (SSR) and static site generation (SSG) capabilities, requires some changes when integrating client-side DevLink components and interactions.
Styles and interactions
To support interactions, your application must be wrapped with the DevLinkProvider
component.
App Router
Pages Router
When using the Next.js App Router in versions 13 and higher, you’ll need to:
- Import and set up the
DevLinkProvider
in your rootlayout.tsx
file - Import global styles from DevLink
React Server Components
The Next.js App Router uses React Server Components by default. For exported Webflow components that rely on client-side JavaScript for interactions and styling, you may need to add the "use client"
directive at the top of your component files.
Links and Images
Some frameworks like Next.js provide their own Link and Image components for use in applications. You can choose to override DevLink’s builtin Link and Image components with the ones from Next.js by passing a custom component to the renderLink
and/or renderImage
props of the <DevLinkProvider>
component.
Update the Next.js Configuration
Update the Next.js configuration to ensure Image components work with external URLs.
Remix
Remix is a full-stack web framework that prioritizes web standards and performance. When using DevLink with Remix:
- Client-side rendering: Make sure that components relying on DevLink’s JavaScript interactions are rendered client-side. You may need to use
useEffect
or other client-side hydration techniques for dynamic content. - Styling: Import the DevLink
global.css
within your rootapp/root.tsx
or a relevant stylesheet. Address any CSS conflicts with Remix’s default styles or your custom CSS. - Data loading: Integrate DevLink components with Remix’s data loading mechanisms (e.g.,
loader
functions) by passing fetched data as props to your DevLink-wrapped components.
Example
Gatsby
Gatsby is a static site generator for React. You can use DevLink components inside your Gatsby project for both static and interactive content. Follow the steps below to integrate DevLink.
Static and interactive components
- Static components are purely presentational and work seamlessly with Gatsby’s static generation.
- Interactive components rely on
window
, animations, or JavaScript APIs and need to be hydrated on the client. UseuseEffect
or a mounted state guard to avoid hydration mismatches.
Example
Styling
Import DevLink’s global stylesheet so your components render with the expected styles. You can do this in either:
gatsby-browser.tsx
to apply styles on the client, or- A shared layout component to ensure styles are included during SSR.
DevLinkProvider
To give all routes access to DevLink, wrap your app root element with DevLinkProvider
. Add the wrapper to both gatsby-browser.tsx
and gatsby-ssr.tsx
.