@fillout/react

中文文档
3.1.2发布于 2026/04/10MITTypeScriptESM + CJS零依赖近 30 天下载 9.4万

Embed Fillout forms in your React project

原始使用文档
文档目录9 节
  1. Setup
  2. Embed components
  3. Standard embed
  4. FullScreen embed
  5. Popup embed
  6. Slider embed
  7. Popup and Slider embed buttons
  8. Listening for form events
  9. Custom domains

Fillout React Embeds

Embed Fillout forms directly in your React project. TypeScript included, no dependencies :)

Hint: If you're looking to use the Fillout API in Node.js, try @fillout/api!

Setup

Install with npm i @fillout/react

Embed components

There is a component for each embed type. All of them require the filloutId prop, which is the id of your form. This code is easy to spot in the url of the editor or the live form, for example, forms.fillout.com/t/foAdHjd1Duus.

All embed components allow you to pass URL parameters using the optional parameters prop, and you can also use inheritParameters to make the form inherit the parameters from the host page's url.

Standard embed

This one is pretty simple.

import { FilloutStandardEmbed } from "@fillout/react";

function App() {
  return (
    <div
      style={{
        width: 400,
        height: 400,
      }}
    >
      <FilloutStandardEmbed filloutId="foAdHjd1Duus" />
    </div>
  );
}

export default App;

If you'd rather not set the embed height manually and instead have it expand to the form size, use the dynamicResize prop.

FullScreen embed

The FilloutFullScreenEmbed component fills the entire page, with position: fixed.

import { FilloutFullScreenEmbed } from "@fillout/react";

function App() {
  return <FilloutFullScreenEmbed filloutId="foAdHjd1Duus" inheritParameters />;
}

export default App;

Popup embed

This component creates a popup, with a dark background covering the page content behind. Unlike the FullScreen embed, it can be closed using the close button or by clicking outside of the popup.

popup screenshot

You control it using your own state. The isOpen and onClose props are required.

import { useState } from "react";
import { FilloutPopupEmbed } from "@fillout/react";

function App() {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <>
      <button onClick={() => setIsOpen(true)}>Schedule a call</button>

      <FilloutPopupEmbed
        filloutId="foAdHjd1Duus"
        isOpen={isOpen}
        onClose={() => setIsOpen(false)}
      />
    </>
  );
}

export default App;

Slider embed

Similar to the popup embed, this is intended to be used alongside your own button and state, so the component requires isOpen and onClose props. The form will slide out from the side of the screen. You can control which direction it comes from using sliderDirection, which can be left or right (default).

slider screenshot

import { useState } from "react";
import { FilloutSliderEmbed } from "@fillout/react";

function App() {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <>
      <button onClick={() => setIsOpen(true)}>Schedule a call</button>

      <FilloutSliderEmbed
        filloutId="foAdHjd1Duus"
        inheritParameters
        parameters={{
          example: "abc",
        }}
        isOpen={isOpen}
        onClose={() => setIsOpen(false)}
        sliderDirection="left"
      />
    </>
  );
}

export default App;

Popup and Slider embed buttons

If you would prefer not to manage the open state of a popup or slider yourself, you can use FilloutPopupEmbedButton or FilloutSliderEmbedButton. This will render a button that opens the embed when clicked. These components take the same props as their standalone counterparts (except for isOpen and onClose), but have some extra optional props to customize the button.

  • text - change the button text
  • color - change the button background color. the text color will automatically contrast with this as long as you specify a hex code.
  • size - small, medium or large
  • float - make your button float on the screen. bottomLeft or bottomRight.
import { FilloutSliderEmbedButton } from "@fillout/react";

function App() {
  return (
    <FilloutSliderEmbedButton
      filloutId="foAdHjd1Duus"
      inheritParameters
      parameters={{
        example: "abc",
      }}
      sliderDirection="left"
      text="Schedule a call"
      color="#444444"
      size="small"
      float="bottomRight"
    />
  );
}

export default App;

If you need greater control over the button appearance, you can just make your own and use it in conjunction with the standalone embed components.

Listening for form events

You can listen for certain form events using the onInit, onPageChange and onSubmit props. Each of these give the submission UUID as the first parameter, and the onPageChange prop gives the page ID as the second parameter.

import { FilloutStandardEmbed } from "@fillout/react";

function App() {
  return (
    <FilloutStandardEmbed
      filloutId="4SVaJQNVdrus"
      dynamicResize
      onInit={(submissionUuid) => {
        console.log(
          `User started filling out the form (submission ID: ${submissionUuid})`
        );
      }}
      onPageChange={(submissionUuid, pageId) => {
        if (pageId === "qTcp") {
          console.log("User is on the review step");
        }
      }}
      onSubmit={async (submissionUuid) => {
        const email = await doSomethingOnYourServer(submissionUuid);
        console.log(`${email} finished filling out the form`);
      }}
    />
  );
}

export default App;

This can be used in conjunction with the @fillout/api package on your server to get information about the structure of your form and to fetch field values once you have the submission UUID.

⚠️ The onPageChange may be triggered for any page on your form, including the starting page when the embed first loads. You should always check the page ID instead of making assumptions about where the user is in the form just because the function was triggered.

Custom domains

If you want to take advantage of features that are only available with forms hosted on your own domain, such as custom JS, you can use the domain prop to change the embedded url.

import { FilloutFullScreenEmbed } from "@fillout/react";

function App() {
  return (
    <FilloutFullScreenEmbed filloutId="foAdHjd1Duus" domain="example.com" />
  );
}

export default App;

版本与发布记录

@fillout/react 共发布 55 个版本,首次发布于 2023/10/17;过去 12 个月发布了 2 个版本。

版本发布日期距今
3.1.2latest2026/04/107 个月前
3.1.02026/04/077 个月前
3.0.02025/04/271.5 年前
2.0.122025/04/181.6 年前
2.0.112025/03/281.6 年前
2.0.102025/03/241.6 年前

关于 @fillout/react 的常见问题

@fillout/react 是什么?

Embed Fillout forms in your React project

如何安装 @fillout/react?

在项目目录运行 npm install @fillout/react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0 || ^19.0 || ^19.0.0-rc)、react-dom(^18.0 || ^19.0 || ^19.0.0-rc)、@types/react(*)、@types/react-dom(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fillout/react 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fillout/react 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@fillout/react 可以商用吗?

@fillout/react 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fillout/react 的下载量有多少?

根据 npm 官方下载统计,@fillout/react 在 2026/10/15 – 2026/11/13 这 30 天内被下载 94,081 次,日均约 3,136 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fillout/react 还在维护吗?

最新版本 3.1.2 发布于 2026/04/10(7 个月前);至今共发布 55 个版本,其中过去 12 个月发布了 2 个;首次发布于 2023/10/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。