@addpipe/react-pipe-media-recorder

中文文档
1.3.0发布于 2026/06/25MITTypeScriptCommonJS近 30 天下载 1.7万

A React custom hook that integrates the addpipe.com recording client

原始使用文档
文档目录11 节
  1. Features:
  2. Installation
  3. Usage Examples
  4. Inserting a single recorder into the page
  5. Inserting a single recorder loaded from our EU client deliv…
  6. Pinning a specific recording-client version
  7. Inserting multiple recorders into the page
  8. Controlling the Recorder
  9. Embed Code Parameters
  10. Documentation and Pricing
  11. Keywords

React Pipe Media Recorder

@addpipe/react-pipe-media-recorder provides a fully typed React hook for both TypeScript and JavaScript integrations that introduces the Pipe Platform into your React projects. This package allows video, audio, and screen + camera recording. It's ideal for applications that need to capture user-generated content such as video feedback, messages, resumes, or testimonials. The recorder is easy to set up and ensures cross-platform compatibility, working on both desktop and mobile devices.

With @addpipe/react-pipe-media-recorder, you can:

  • Record high-quality audio and video content directly from users.
  • Capture screen and camera for detailed visual feedback or presentations.
  • Embed multiple recorders on a page for various user interactions.

Note: You will need a free trial or paid account with Addpipe to use this package.

How it loads: As of version 1.3.0, the recording client is bundled directly via the @addpipe/pipe-recording-client npm package instead of being injected into the page through remote <script>/<link> tags. The Pipe recording client is imported by the hook, so your bundler (Vite, webpack, Next.js, CRA, …) handles them automatically, no extra setup is required. The recorder still communicates with Pipe's servers at runtime; only how the client is loaded has changed. The recording client version follows this package's @addpipe/pipe-recording-client dependency range (^2.0.0); see Pinning a specific recording-client version if you need to lock it to an exact release.

Features:

  • Video, Audio, and Screen Recording: Add high-quality media recording functionality to any React app, supporting both desktop and mobile devices.
  • Up to 4K Video: Supports recording up to 4K resolution.
  • No Upload Time: Stream recordings while they are created, minimizing the wait time for users.
  • Mobile Compatibility: Supports HTML Media Capture for mobile video/audio recording.
  • Screen + Camera Recording: Capture both the screen and camera simultaneously for enhanced recording capabilities.
  • Multilingual Support: Available in multiple languages: English, French, German, and Spanish, with custom language support.
  • Keyboard Accessibility: Fully controllable via keyboard for improved accessibility.
  • Connection Resilience: Auto-reconnect ensures data recovery if the connection drops during recording.

Installation

Install the package using npm:

npm install @addpipe/react-pipe-media-recorder

Usage Examples

👉 Working Demo: You can find a working demo here. The source code for the demo is available in both JavaScript and TypeScript React. Find more about it here.

Inserting a single recorder into the page

In this example, we insert a single Pipe recorder into the page and control it using the recorder's API (record() and stopVideo()).

import { useState } from "react";
import usePipeSDK from "@addpipe/react-pipe-media-recorder"; // Importing the Pipe recorder npm package

// Inserting a single Pipe recorder into the page
const SingleRecorder = () => {
  // Storing the generated recorder inside of a state - optional
  const [recorder, setRecorder] = useState(null);
  const [canRecord, setCanRecord] = useState(false);

  // Using the Pipe recorder custom hook
  const { isLoaded } = usePipeSDK((PipeSDK) => {
    // Check to make sure the code below is only executed on the initial load
    if (isLoaded) return;

    // Prepare the parameters needed to generate a new recorder
    const pipeParams = { size: { width: 640, height: 390 }, qualityurl: "avq/360p.xml", accountHash: "YOUR_ACCOUNT_HASH", eid: "YOUR_ENV_CODE", mrt: 600, avrec: 1 };

    // Inserting a new recorder into the page
    PipeSDK.insert("custom-id", pipeParams, (pipeRecorder) => {
      setRecorder(pipeRecorder); // Store the recorder instance for later use
      pipeRecorder.onReadyToRecord = () => {
        setCanRecord(true);
      }
    });
  });

  // Function to start a new recording using the recorder's API
  const startRecording = () => {
    if (!recorder || !canRecord) return;
    recorder.record(); // Call to start recording
  };

  // Function to stop a recording using the recorder's API
  const stopRecording = () => {
    if (!recorder || !canRecord) return;
    recorder.stopVideo(); // Call to stop recording
  };

  return (
    <div>
      {!isLoaded && <div>Loading the Pipe recorder</div>}
      <div id="custom-id"></div> {/* Placeholder for where the new recorder should be inserted */}
      {isLoaded && recorder && (
        <>
          {/* Buttons to control the recorder - Only display them after all prerequisites have loaded */}
          <button onClick={startRecording}>Record</button>
          <button onClick={stopRecording}>Stop</button>
        </>
      )}
    </div>
  );
};

export default SingleRecorder;

Inserting a single recorder loaded from our EU client delivery servers (S1)

In this example, we insert a single Pipe recorder into the page and control it using the recorder's API (record() and stopVideo()). We load its static assets from our EU client delivery servers (S1) instead of the default global CDN by passing useS1: true.

Deprecated: The buildSlug option no longer has any effect and is kept only for backward compatibility. It used to request a specific pipe.min.js/pipe.min.css release; the recording-client version is now determined by the installed @addpipe/pipe-recording-client dependency. Passing buildSlug logs a one-time console warning. To control the client version, see Pinning a specific recording-client version below.

import { useState } from "react";
import usePipeSDK from "@addpipe/react-pipe-media-recorder"; // Importing the Pipe recorder npm package

// Inserting a single Pipe recorder into the page
const SingleRecorder = () => {
  // Storing the generated recorder inside of a state - optional
  const [recorder, setRecorder] = useState(null);
  const [canRecord, setCanRecord] = useState(false);

  // Custom options
  const options = {
    useS1: true, // Load from our EU client delivery servers (S1)
  }

  // Using the Pipe recorder custom hook with S1
  const { isLoaded } = usePipeSDK((PipeSDK) => {
    // Check to make sure the code below is only executed on the initial load
    if (isLoaded) return;

    // Prepare the parameters needed to generate a new recorder
    const pipeParams = { size: { width: 640, height: 390 }, qualityurl: "avq/360p.xml", accountHash: "YOUR_ACCOUNT_HASH", eid: "YOUR_ENV_CODE", mrt: 600, avrec: 1 };

    // Inserting a new recorder into the page
    PipeSDK.insert("custom-id", pipeParams, (pipeRecorder) => {
      setRecorder(pipeRecorder); // Store the recorder instance for later use
      pipeRecorder.onReadyToRecord = () => {
        setCanRecord(true);
      }
    });
  }, options);

  // Function to start a new recording using the recorder's API
  const startRecording = () => {
    if (!recorder || !canRecord) return;
    recorder.record(); // Call to start recording
  };

  // Function to stop a recording using the recorder's API
  const stopRecording = () => {
    if (!recorder || !canRecord) return;
    recorder.stopVideo(); // Call to stop recording
  };

  return (
    <div>
      {!isLoaded && <div>Loading the Pipe recorder</div>}
      <div id="custom-id"></div> {/* Placeholder for where the new recorder should be inserted */}
      {isLoaded && recorder && (
        <>
          {/* Buttons to control the recorder - Only display them after all prerequisites have loaded */}
          <button onClick={startRecording}>Record</button>
          <button onClick={stopRecording}>Stop</button>
        </>
      )}
    </div>
  );
};

export default SingleRecorder;

Pinning a specific recording-client version

This package depends on @addpipe/pipe-recording-client with the range ^2.0.0, so by default you get the latest compatible 2.x recording client. This is the modern replacement for the old buildSlug option.

To lock the recording client to an exact client version, override the dependency from your own project's package.json (not this package's). The recording client bundled into your app is whatever version resolves there.

npm (v8.3+) - add an overrides field:

{
  "overrides": {
    "@addpipe/pipe-recording-client": "2.0.0"
  }
}

Yarn / pnpm - add a resolutions field:

{
  "resolutions": {
    "@addpipe/pipe-recording-client": "2.0.0"
  }
}

Then reinstall (npm install, yarn, or pnpm install) and confirm the resolved version with npm ls @addpipe/pipe-recording-client. Available versions are listed on the recording-client versions page.

Inserting multiple recorders into the page

This example demonstrates how to insert multiple Pipe recorders into the page.

import { useState } from "react";
import usePipeSDK from "@addpipe/react-pipe-media-recorder"; // Importing the Pipe recorder npm package

// Inserting multiple Pipe recorders into the page
const MultipleRecorders = () => {
  // Storing the global PipeSDK into a state
  const [pipeSdk, setPipeSdk] = useState(null);

  // Custom IDs for the recorders
  const CUSTOM_IDS = ["custom-id-1", "custom-id-2", "custom-id-3"];

  // Using the Pipe recorder custom hook
  const { isLoaded } = usePipeSDK((PipeSDK) => {
    // Check to make sure the code below is only executed on the initial load
    if (isLoaded) return;

    // Prepare the parameters needed to generate new recorders
    const pipeParams = { size: { width: 640, height: 390 }, qualityurl: "avq/360p.xml", accountHash: "YOUR_ACCOUNT_HASH", eid: "YOUR_ENV_CODE", mrt: 600, avrec: 1 };

    // Inserting new recorders into the page
    CUSTOM_IDS.forEach((id) => PipeSDK.insert(id, pipeParams, () => {}));

    // Store PipeSDK into a state for controlling the recorders later
    setPipeSdk(PipeSDK);
  });

  // Function to start a new recording using PipeSDK
  const startRecording = (recorderId) => {
    if (!pipeSdk) return;
    pipeSdk.getRecorderById(recorderId).record(); // Call to start recording for a specific recorder
  };

  // Function to stop a recording using PipeSDK
  const stopRecording = (recorderId) => {
    if (!pipeSdk) return;
    pipeSdk.getRecorderById(recorderId).stopVideo(); // Call to stop recording for a specific recorder
  };

  return (
    <>
      {CUSTOM_IDS.map((id, index) => (
        <div key={index}>
          <div id={id}></div> {/* Placeholder for where the new recorder should be inserted */}
          {/* Buttons to control the recorder - Only display them after all prerequisites have loaded */}
          {isLoaded && (
            <>
              <button onClick={() => startRecording(id)}>Record</button>
              <button onClick={() => stopRecording(id)}>Stop</button>
            </>
          )}
        </div>
      ))}
    </>
  );
};

export default MultipleRecorders;

Controlling the Recorder

To control the recorders, you can use the API control methods, such as:

  • record(): Starts a new recording.
  • stopVideo(): Stops the recording.

A full list of the recorder's API control methods can be found in the official Pipe API Documentation.

Embed Code Parameters

The pipeParams object is used to configure the Pipe recorder. Here’s an example of its structure:

const pipeParams = {
  size: { width: 640, height: 390 },
  qualityurl: "avq/360p.xml",
  accountHash: "YOUR_ACCOUNT_HASH",
  eid: "YOUR_ENV_CODE",
  mrt: 600,
  avrec: 1,
  // Additional options available in the official documentation
};

For more detailed embed code options, refer to the Addpipe Embed Code Options.

Documentation and Pricing


Keywords

  • Video Recorder
  • Video Recording
  • Audio Recorder
  • Audio Recording
  • Screen Recorder
  • Screen Recording
  • Camera Recorder
  • React Video Recorder
  • React Audio Recorder
  • Screen and Camera Capture
  • React Hooks for Media

Releases

All releases are available here

版本与发布记录

@addpipe/react-pipe-media-recorder 共发布 12 个版本,首次发布于 2024/11/05;过去 12 个月发布了 4 个版本。

版本发布日期距今
1.3.0latest2026/06/254 个月前
1.2.02025/12/1610 个月前
1.1.12025/12/0211 个月前
1.1.02025/11/1911 个月前
1.0.72025/11/041 年前
1.0.62025/02/131.7 年前

关于 @addpipe/react-pipe-media-recorder 的常见问题

@addpipe/react-pipe-media-recorder 是什么?

A React custom hook that integrates the addpipe.com recording client

如何安装 @addpipe/react-pipe-media-recorder?

在项目目录运行 npm install @addpipe/react-pipe-media-recorder,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16.8.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@addpipe/react-pipe-media-recorder 支持 TypeScript 吗?

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

@addpipe/react-pipe-media-recorder 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@addpipe/react-pipe-media-recorder 可以商用吗?

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

@addpipe/react-pipe-media-recorder 的下载量有多少?

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

@addpipe/react-pipe-media-recorder 还在维护吗?

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