@daily-co/daily-react

中文文档
0.26.1发布于 2026/10/16BSD-2-ClauseTypeScriptESM + CJS构建来源已验证近 30 天下载 84.4万

Daily React makes it easier to integrate @daily-co/daily-js in React applications.

原始使用文档
文档目录4 节
  1. Usage
  2. Installation
  3. Tests
  4. Contributions

Daily React

Daily React makes it easier to integrate @daily-co/daily-js in React applications.

Usage

To get started with Daily React, include DailyProvider in your app:

import { DailyProvider } from '@daily-co/daily-react';

function App({ roomUrl }) {
  return <DailyProvider url={roomUrl}>{/* … */}</DailyProvider>;
}

Then in your application you can access Daily React:

import {
  useParticipantIds,
  useParticipantProperty,
} from '@daily-co/daily-react';

function ParticipantRow({ id }) {
  const [username, videoState, audioState] = useParticipantProperty(id, [
    'user_name',
    'tracks.video.state',
    'tracks.audio.state',
  ]);

  return (
    <li style={{ display: 'flex', gap: 8 }}>
      <span>{username ?? 'Guest'}</span>
      <span>📷{videoState === 'playable' ? '✅' : '❌'}</span>
      <span>🎙️{audioState === 'playable' ? '✅' : '❌'}</span>
    </li>
  );
}

function Participants() {
  const participantIds = useParticipantIds({
    filter: 'remote',
    sort: 'user_name',
  });

  return (
    <ul>
      {participantIds.map((id) => (
        <ParticipantRow key={id} id={id} />
      ))}
    </ul>
  );
}

Learn more about Daily React by reading our docs at https://docs.daily.co/reference/daily-react.

Installation

The daily-react package is published to npm. To install the latest stable version, run one of the following commands:

npm install @daily-co/daily-react @daily-co/daily-js jotai

# or with yarn

yarn add @daily-co/daily-react @daily-co/daily-js jotai

Notice that @daily-co/daily-react requires @daily-co/daily-js and jotai as peer dependencies.

@daily-co/daily-react manages its internal state using jotai. You can read more about jotai in their Introduction.

Tests

We've set up automatic tests using jest and Testing Library. You can run the tests using the following command:

npm test

# or with yarn

yarn test

Contributions

Please head over to our contributing guide to learn more about how you can contribute to daily-react.

In case you've got general questions about Daily or need technical assistance, please reach out via [email protected].

版本与发布记录

@daily-co/daily-react 共发布 46 个版本,首次发布于 2022/11/15;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.26.1latest2026/10/1625 天前
0.26.02026/07/153 个月前
0.25.32026/06/254 个月前
0.25.22026/05/135 个月前
0.25.12026/04/306 个月前
0.25.02026/04/216 个月前

关于 @daily-co/daily-react 的常见问题

@daily-co/daily-react 是什么?

Daily React makes it easier to integrate @daily-co/daily-js in React applications.

如何安装 @daily-co/daily-react?

在项目目录运行 npm install @daily-co/daily-react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:jotai(^2)、react(^16.8 || ^17.0 || ^18.0 || ^19.0)、react-dom(^16.8 || ^17.0 || ^18.0 || ^19.0)、@daily-co/daily-js(>=0.68.0 <1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@daily-co/daily-react 支持 TypeScript 吗?

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

@daily-co/daily-react 支持 ESM 还是 CommonJS?

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

@daily-co/daily-react 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=12。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@daily-co/daily-react 可以商用吗?

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

@daily-co/daily-react 的下载量有多少?

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

@daily-co/daily-react 还在维护吗?

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