Webflow Code Components: Bring React Components Into Webflow With DevLink (Tested With CLI 2.18)
How to build a React code component for Webflow, describe its props and import it with the DevLink commands, and three things older tutorials get wrong.

Webflow interactions can show, hide and animate, but they can’t hold state: a price switch that recalculates, a calculator, a filter that remembers what you picked. For that you used to paste JavaScript into an Embed element and hope it ran in the right order. Code components are the supported way now: you write a React component in your own repository, describe its props, and import it into Webflow, where designers drop it onto pages and edit its props in the Designer like any other element.
We built a monthly/yearly price toggle as a code component with the current packages (Webflow CLI 2.18.0, @webflow/react and @webflow/data-types 2.11.0), bundled it and ran the import checks. Here is the whole project, and three things the older tutorials get wrong.

Download the example project (source only; run npm install first).
The project
Three files per component, plus a manifest:
webocreation-code-components/
package.json
tsconfig.json
webflow.json
src/components/PriceToggle/
PriceToggle.tsx the React component
PriceToggle.css its styles
PriceToggle.webflow.tsx what Webflow sees: name, group and props
Install the CLI and the two Webflow packages next to React:
npm i --save-dev @webflow/webflow-cli @webflow/data-types @webflow/react react react-dom typescript @types/react
1. The React component
An ordinary React component with typed props and a little state. Nothing in it is specific to Webflow:
import { useState } from "react";
import "./PriceToggle.css";
type Props = {
monthly: number;
yearly: number;
currency: string;
showSaving: boolean;
};
// A monthly/yearly price switch: real state, which Webflow interactions alone can't hold.
export function PriceToggle({ monthly, yearly, currency, showSaving }: Props) {
const [period, setPeriod] = useState<"month" | "year">("month");
const price = period === "month" ? monthly : yearly;
const saving = Math.round((1 - yearly / (monthly * 12)) * 100);
return (
<div className="pt">
<div className="pt-switch" role="group" aria-label="Billing period">
<button type="button" aria-pressed={period === "month"} onClick={() => setPeriod("month")}>Monthly</button>
<button type="button" aria-pressed={period === "year"} onClick={() => setPeriod("year")}>
Yearly{showSaving && saving > 0 ? ` (save ${saving}%)` : ""}
</button>
</div>
<p className="pt-price" aria-live="polite">
{currency}{price.toLocaleString()} <span>/ {period}</span>
</p>
</div>
);
}
2. The Webflow definition
declareComponent() wraps the component and maps each prop to a control in the Designer’s properties panel: a number field, a text field and an on/off switch here. This file is what the CLI collects:
import { declareComponent } from "@webflow/react";
import { props } from "@webflow/data-types";
import { PriceToggle } from "./PriceToggle";
export default declareComponent(PriceToggle, {
name: "Price Toggle",
description: "Monthly or yearly price with a switch",
group: "Pricing",
props: {
monthly: props.Number({ name: "Monthly price", defaultValue: 19, min: 0 }),
yearly: props.Number({ name: "Yearly price", defaultValue: 190, min: 0 }),
currency: props.Text({ name: "Currency symbol", defaultValue: "$" }),
showSaving: props.Boolean({ name: "Show yearly saving", defaultValue: true, trueLabel: "Show", falseLabel: "Hide" }),
},
});
Other prop types include props.Link, props.Image, props.RichText, props.Variant (a dropdown) and props.Slot for nesting other elements. Prop names beginning with __wf_ are reserved; the bundle is rejected if you use one.
3. The manifest
webflow.json names the library and tells the CLI where the definitions are:
{
"library": {
"name": "Webocreation Components",
"id": "webocreation-components",
"components": [
"src/components/**/*.webflow.tsx"
]
}
}
Bundle, check, import
Bundle locally to catch errors before anything leaves your machine:
npx webflow devlink bundle
Then run every import check without uploading, and finally import the library into your Workspace (the first real import asks you to sign in or pass an API token):
npx webflow devlink import --dry-run
npx webflow devlink import
After the import, the components appear in the Designer’s Components panel under the library name and group, ready to drag onto a page.
Three things older tutorials get wrong
- The commands moved. Most guides say
npx webflow library shareandwebflow library bundle. In CLI 2.18.0 the wholelibrarygroup is marked deprecated and will be removed in the next major release; usewebflow devlink importandwebflow devlink bundle. - The manifest needs an id. A
webflow.jsonwith onlynameandcomponents, as in many examples, failed with “Library manifest does not have an id”. Add a stableid. - Telemetry is on by default. The first command switched on usage and error reporting and wrote a config file to
~/.config/webflow/. Turn it off withnpx webflow auth telemetry --disableif your company requires it.
How code components behave on the page
- They render on the server by default and hydrate in the browser, so visitors and search engines get real HTML. Set
options: { ssr: false }in the definition for components that only make sense in the browser. - Styles stay inside the component. Plain CSS imported by the component works, as above. CSS-in-JS libraries need a decorator, such as
emotionShadowDomDecoratorfrom@webflow/emotion-utils, because the components render inside a shadow DOM. - Webflow context:
useWebflowContext()from@webflow/reacttells the component whether it is in the Designer or on the live site, whether it is interactive, and the current locale. - Weight: our one small component bundled to 738.8 KB in total (React included) across the client and server bundles. Keep components few and focused; see loading scripts in Webflow without hurting Core Web Vitals.
When to use Embeds and custom code instead
Code components suit interactive pieces that designers should place and configure themselves. A tracking script, a site-wide widget or a quick one-off is still simpler as custom code; our guides on where custom code runs in Webflow and a local workflow for Webflow custom code cover that side.
How we tested
Node.js with the package versions above: the component type-checked with tsc, rendered on the server with React 19 (Monthly selected, “$19 / month”, “Yearly (save 17%)”), switched to “$190 / year” when clicked in a browser, bundled with webflow devlink bundle, and passed webflow devlink import --dry-run. We didn’t import it into a live Workspace.
Related
- Where custom code runs in Webflow
- A local dev workflow for Webflow custom code
- Third-party scripts and Core Web Vitals in Webflow







